Expand my Community achievements bar.

SOLVED

AEM 6.5.19 Sling Model is not being registered

Avatar

Level 3

Hi,

 

I am using AEM 6.5.19 and created a simple sling servlet adapting to Resource. However when I use the sling model in html, getting the following error:

 

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier com.kishore.project.core.models.kishoremodel
at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:510) [org.apache.sling.scripting.core:2.3.2]
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:579) [org.apache.sling.engine:2.7.10.B0006]
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45) [org.apache.sling.engine:2.7.10.B0006]

 

When i check inn status-sling models, not finding my sling model.

 

Question: Do i need to include anything in the POM.xml to support sling models? Please note my project was generated using Maven archetype 39.

 

Any help is highly appriciated.

 

Regards,

Kishore

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @kishored6899358 ,

Sling model should be in TitleCase, change it to Kishoremodel in java and sightly both.

MukeshYadav__0-1731425836555.png

Thanks

View solution in original post

6 Replies

Avatar

Community Advisor

Hi Kishore,

 

It could be one of the two reasons mentioned below: 

  • package-info.json may not be present in the package. In your case, this package - com.kishore.project.core.models 
  • Sling-Model-Packages may have incorrect package path. Check the bnd-maven-plugin configuration in pom.xml 

I came across this answer https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/what-s-the-advantage-of-us... in the community which has great details on different approaches of sling model exporters. 

 

Thanks,

Lokesh

Avatar

Level 3

Hi @Lokesh_Vajrala 

Thank you for your reply

 

The package-info.json is available under models

@Version("1.0")
package com.kishore.project.core.models;

import org.osgi.annotation.versioning.Version;


And using ModelsScannerPlugin for sling model registration.

 

kishored6899358_0-1731422297002.png

Regards,

Kishore

Avatar

Community Advisor

Hi @kishored6899358 ,

You may check typo in model call- 

<sly data-sly-use.model="com.kishore.project.core.models.kishoremodel" /> 

try K of Kishoremodel in camelcae as most probably your sling model would be in TitleCase

 

Cross check if package-info.java file present

Check the import statements

Thanks

Avatar

Level 3

Hi @MukeshYadav_ 

 

The model is in lowercase only and the package-info.json is available under the models.

 

Regards,

Kishore

Avatar

Correct answer by
Community Advisor

Hi @kishored6899358 ,

Sling model should be in TitleCase, change it to Kishoremodel in java and sightly both.

MukeshYadav__0-1731425836555.png

Thanks