I am getting below error while using data-sly-use to call Java class method. what can be the issue ? any configuration issue ?
17.06.2020 01:37:28.281 *ERROR* [0:0:0:0:0:0:0:1  GET /content/we-retail/us/en/sample.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: path='/content/we-retail/us/en/sample/jcr:content/root/responsivegrid/customcomponent', selectorString='null', extension='html', suffix='null' org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier mycomponent at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:510) [org.apache.sling.scripting.core:2.0.56] at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552) [org.apache.sling.engine:2.6.18] at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:44) [org.apache.sling.engine:2.6.18] at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:82) [org.apache.sling.engine:2.6.18]
@arunk85184451 I read from the comments that you have your Java class in the same folder. This error clearly says that the Java class is not available. In your case it can be because that the Java Class is not compiled properly. If you see that your Java Class name is in small letters. As per Java standards and compiler , you need your Class name to start with Capital case. This will compile your Java classes properly and this issue should get resolved I believe. Please change your Java class name to MyComponent.java and test this
Disclaimer:- I am not 100% sure on this since I have never used Java class inside component. but give it a try 😉 and let us know
Side note:- I would recommend always writing Sling Models rather than writing it inside the component folder itself.
you have used mycomponent.java class as <div data-sly-use.titleobj="mycomponent"> when you specify java class without its package name, it means the java class is expected to be present in the same folder where your HTL file is present.
Looking at the exception you are getting, it is clear the class is not present in the same folder of your component . You have to specify your class with package name.
For ex: if class is present in package com.myproject.mymodels.mycomponent, then, the use include should be