Getting error msg 'No use provider could resolve identifier' when using sling model in HTL | Community
Skip to main content
Level 2
January 4, 2017
Solved

Getting error msg 'No use provider could resolve identifier' when using sling model in HTL

  • January 4, 2017
  • 12 replies
  • 14309 views

Hi,

I've created a project using Maven Archetype 10 that has the below sample model object and htl file. The code was compiled and deployed to local repository using the mvn command: mvn -PautoInstallPackage install. Please note, the model object is in a seperate bundle.

**************************

package AEM62App.core.models;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.settings.SlingSettingsService;

@Model(adaptables=Resource.class)
public class HelloWorldModel {

    @Inject
    private SlingSettingsService settings;

    @Inject @Named("sling:resourceType") @Default(values="No resourceType")
    protected String resourceType;

    private String message;

    @PostConstruct
    protected void init() {
        message = "\tHello World!\n";
        message += "\tThis is instance: " + settings.getSlingId() + "\n";
        message += "\tResource type is: " + resourceType + "\n";
    }

    public String getMessage() {
        return message;
    }
}

*** and helloworld.html *******************

<p data-sly-test="${properties.text}">Text property: ${properties.text}</p>

<pre data-sly-use.hello="AEM62App.core.models.HelloWorldModel">
HelloWorldModel says:
${hello.message}
</pre>

*****

However, when helloworld component is invoked, it is throwing the below error. Please let me know if I'm missing anything.

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.sightly.SightlyException: No use provider could resolve identifier AEM62App.core.models.HelloWorldModel

org.apache.sling.api.scripting.ScriptEvaluationException: org.apache.sling.scripting.sightly.SightlyException: No use provider could resolve identifier AEM62App.core.models.HelloWorldModel at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:416) at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184) at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491) at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:546) at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:77) at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:187) at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:154) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68) at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:265) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68) at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilter(WCMDeveloperModeFilter.java:114) at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:68) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:282) at org.apache.sling.engine.impl.SlingRequestProcessorImpl.dispatchRequest(SlingRequestProcessorImpl.java:322) at org.apache.sling.engine.impl.request.SlingRequestDispatcher.dispatch(SlingRequestDispatcher.java:211) at org.apache.sling.engine.impl.request.SlingRequestDispatcher.include(SlingRequestDispatcher.java:104) at com.day.cq.wcm.core.impl.WCMComponentFilter$ForwardRequestDispatcher.include(WCMComponentFilter.java:503) at com.adobe.cq.sightly.WCMScriptHelper.includeResource(WCMScriptHelper.java:165) at com.adobe.cq.sightly.internal.extensions.ResourceExtension.call(ResourceExtension.java:128) at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:66) at org.apache.sling.scripting.sightly.libs.wcm.foundation.components.parsys.SightlyJava_parsys.render(SightlyJava_parsys.java:229) at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderUnit.render(RenderUnit.java:54) at org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.evaluateScript(SightlyScriptEngine.java:92) at org.apache.sling.scripting.sightly.impl.engine.SightlyScriptEngine.eval(SightlyScriptEngine.java:78)

Regards,

Yogesh.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

It means that the use-class can't be instantiated.

Can you try first to make the whole package-name lowercase?

It is normal to have the Java package in lowercase.

12 replies

Feike_Visser1
Adobe Employee
Feike_Visser1Adobe EmployeeAccepted solution
Adobe Employee
January 4, 2017

It means that the use-class can't be instantiated.

Can you try first to make the whole package-name lowercase?

It is normal to have the Java package in lowercase.

July 25, 2023

I have make the whole package-name in lowercase but issue is not resolve.

Feike_Visser1
Adobe Employee
Adobe Employee
January 4, 2017

Did you verify that your bundle is active?

January 4, 2017

Can you check if you have added your package name in your POM (core) under <Sling-Model-Packages>? If not, try adding that!

-Khanjan

smacdonald2008
Level 10
January 4, 2017

See our HELPX Article on AEM 6.2 and Sling Models - it will point you in the correct direction: 

Working with Sling Models in Adobe Experience Manager 6.2

Hope this helps... 

Level 2
January 5, 2017

Hi Khanjan,

Yes, I can see sling-model-packages added already in pom.xml. And I believe, adding AEM62App.core will automatically add its child package 'AEM62App.core.models'. Please let me know otherwise.

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Sling-Model-Packages>
                            AEM62App.core
                        </Sling-Model-Packages>
                    </instructions>
                </configuration>
            </plugin>

Regards,

Yogesh.

Level 2
January 5, 2017

Hi smacdonald2008,

Yes, I'm trying that example and getting this error. Thanks.

Regards,

Yogesh.

Feike_Visser1
Adobe Employee
Adobe Employee
January 5, 2017

When you use this archetype, you can't directly deploy on 6.2 without adding dependencies.

Can you check if the bundle is active?

Level 2
January 5, 2017

Hi Feike,

Yes, the bundle is active and i can locate other services present in that bundle from felix console.

Regards,

Yogesh.

Feike_Visser1
Adobe Employee
Adobe Employee
January 5, 2017

Do you see errors in the log-file when you request the page?

smacdonald2008
Level 10
January 5, 2017

There is a video here on this use case - follow the video and make sure you do everything we cover in the video: 

https://www.youtube.com/watch?v=W7jdkhqh8ZY&feature=youtu.be