Whenever I try to add '@Reference' of a service in other java file getting the above error.
If I remove the reference then everything works fine.
ERROR:
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Identifier com.torrid.aem.dynamicmedia.core.models.ReviewDashboardPageModel cannot be correctly instantiated by the Use API
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:552) [org.apache.sling.engine:2.7.2]
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44) [org.apache.sling.engine:2.7.2]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:82) [org.apache.sling.engine:2.7.2]
at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilterWithErrorHandling(WCMDeveloperModeFilter.java:164) [com.day.cq.wcm.cq-wcm-core:5.12.158]
at com.day.cq.wcm.core.impl.WCMDeveloperModeFilter.doFilter(WCMDeveloperModeFilter.java:135) [com.day.cq.wcm.cq-wcm-core:5.12.158]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.7.2]
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilterWithErrorHandling(WCMDebugFilter.java:192) [com.day.cq.wcm.cq-wcm-core:5.12.158]
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:159) [com.day.cq.wcm.cq-wcm-core:5.12.158]
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:72) [org.apache.sling.engine:2.7.2]
at com.adobe.acs.commons.granite.ui.components.impl.include.IncludeDecoratorFilterImpl.doFilter(IncludeDecoratorFilterImpl.java:92)
Appreciate any help regarding the issue.
Thanks,
Nandan
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @nandan123 ,
Looks like you are trying to inject an OSGi service into the sling model.
You need to use @OSGiService annotation instead of @Reference.
Check the documentation here:-
https://sling.apache.org/documentation/bundles/models.html
Also, check if the service you are trying to inject is available on the console.
Hope this helps!
Regards,
Nitesh
Hi @nandan123 ,
Looks like you are trying to inject an OSGi service into the sling model.
You need to use @OSGiService annotation instead of @Reference.
Check the documentation here:-
https://sling.apache.org/documentation/bundles/models.html
Also, check if the service you are trying to inject is available on the console.
Hope this helps!
Regards,
Nitesh
The issue is resolved,
I was referencing Service1 which has reference of Service2 in Service2 itself, which some how got in loop.
Thank you,
Nandan