SlingHttpServletRequest object is null when we pass it to OSGI service from WCMUse class
Hi All,
SlingHttpServletRequest object is null when i am passing it from WCMuse class to an OSGI service . why it will behave like that. Also when we do an getRequest in WCMUse class it returns an org.apache.sling.scripting.core.impl.helper.OnDemandReaderRequest object instead of org.apache.sling.api.SlingHttpServletRequest object. Sample code is as below
public class MyWrapperClass extends WCMUse {
private SlingHttpServletRequest request;
@Override
public void activate() {
request = getRequest(); //here the request object is returning org.apache.sling.scripting.core.impl.helper.OnDemandReaderRequest how we can get org.apache.sling.api.SlingHttpServletRequest
String str = getSlingScriptHelper().getService(MyService.class).myMethod(request);
}
}
@Component (immediate=true, enabled=true)
@Service (value = MyInterface.class)
public class MyService implements MyInterface {
@Override
public String myMethodyMethod(SlingHttpServletRequest request){
request.setAttribute("example","example");// here the request object is coming as null
return "true";
}
}