AEM 6.5.19 Sling Model is not being registered | Community
Skip to main content
Level 3
November 12, 2024
Solved

AEM 6.5.19 Sling Model is not being registered

  • November 12, 2024
  • 2 replies
  • 1157 views

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

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 MukeshYadav_

Hi @kishored6899358 ,

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

Thanks

2 replies

Lokesh_Vajrala
Community Advisor
Community Advisor
November 12, 2024

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-using-package-info-json-vs-export/m-p/670398/highlight/true#M167641 in the community which has great details on different approaches of sling model exporters. 

 

Thanks,

Lokesh

Level 3
November 12, 2024

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.

 

Regards,

Kishore

MukeshYadav_
Community Advisor
Community Advisor
November 12, 2024

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

Level 3
November 12, 2024

Hi @mukeshyadav_ 

 

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

 

Regards,

Kishore

MukeshYadav_
Community Advisor
MukeshYadav_Community AdvisorAccepted solution
Community Advisor
November 12, 2024

Hi @kishored6899358 ,

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

Thanks