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

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

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.
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Jan 4, 2017 12:02 PM UTC

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.

13 replies

Level 2
Jan 8, 2017 2:18 PM UTC

Thank you Feike and all for your help.

The problem was when I created the archetype 10 project, I set the value for 'package' as 'AEM62App'. After resetting it to lowercase, that is, 'com.aem.community', the model started working.

Translate
smacdonald2008
Level 10
Jan 5, 2017 2:58 PM UTC

ALso - - I just tested the package that comes with the article - it works: 

Have you installed the package? 

Translate
smacdonald2008
Level 10
Jan 5, 2017 2:53 PM UTC

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

Translate
Feike_Visser1
Employee
Jan 5, 2017 2:20 PM UTC

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

Translate
Level 2
Jan 5, 2017 2:15 PM UTC

Hi Feike,

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

Regards,

Yogesh.

Translate
Feike_Visser1
Employee
Jan 5, 2017 2:13 PM UTC

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

Can you check if the bundle is active?

Translate
Level 2
Jan 5, 2017 2:10 PM UTC

Hi smacdonald2008,

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

Regards,

Yogesh.

Translate
Level 2
Jan 5, 2017 2:06 PM UTC

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.

Translate
smacdonald2008
Level 10
Jan 4, 2017 3:28 PM UTC

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... 

Translate
New Participant
Jan 4, 2017 2:45 PM UTC

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

-Khanjan

Translate