Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Sling Models

Avatar

Level 2

Hi Everyone, 

When I am trying to add one custom component to a page, I get a SlingException error:

Error : 

org.apache.sling.scripting.sightly.SightlyException: org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.scripting.sightly.SightlyException: Identifier com.mentor.core.core.models.DemoAnnotations cannot be correctly instantiated by the Use API

 

Have tried different things to fix it, but unable to figure out.

Can anyone provide solution on this error? 

1 Accepted Solution

Avatar

Correct answer by
Level 8

Hi @NayanGarade 

Have u used the correct adaptables? Resource.class or SlingHttpServletRequest.class or Both?

Whether all the injectors are compulsory?  Or else, use defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL

 

Add logger in your init method (custom method name might be different) having @PostConstruct annotation

Is log displayed in logger file?

View solution in original post

3 Replies

Avatar

Correct answer by
Level 8

Hi @NayanGarade 

Have u used the correct adaptables? Resource.class or SlingHttpServletRequest.class or Both?

Whether all the injectors are compulsory?  Or else, use defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL

 

Add logger in your init method (custom method name might be different) having @PostConstruct annotation

Is log displayed in logger file?

Avatar

Level 4

Can you please paste your modal class also? One of your identifier is wrong. Mostly wrong annotation scope. Like you have @Resource adaptable, but trying to access higher level context objects. Might need to elevate to @SlingServletReqeust. Difficult to guess without seeing your class. Please share. 

Avatar

Level 9

@NayanGarade : Please share both the component dialog field names and DemoAnnotations code snippet. By looking at that only anyone will be able to tell what could be wrong there.
Also, there could be some more information in the logs about what may be the issue here.