Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

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

Avatar

Level 2

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.

1 Accepted Solution

Avatar

Correct answer by
Employee

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.

View solution in original post

12 Replies

Avatar

Correct answer by
Employee

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.

Avatar

Level 1

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

-Khanjan

Avatar

Level 10

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

Avatar

Level 2

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.

Avatar

Level 2

Hi smacdonald2008,

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

Regards,

Yogesh.

Avatar

Employee

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

Can you check if the bundle is active?

Avatar

Level 2

Hi Feike,

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

Regards,

Yogesh.

Avatar

Employee

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

Avatar

Level 10

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

Avatar

Level 10

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

Have you installed the package? 

Avatar

Level 2

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.