Hi Jörg Hoh,
I have tried above approach, I am ending up with below exception
Caused by: org.apache.sling.models.factory.PostConstructException: Post-construct method has thrown an exception for model class myproject.slingmodels.core.PageImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:705)
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:394)
at org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:261)
Caused by: java.lang.NullPointerException
at myproject.slingmodels.core.PageV1Impl.initModel(PageV1Impl.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.sling.models.impl.ModelAdapterFactory.invokePostConstruct(ModelAdapterFactory.java:896)
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:703)
... 176 more
NullPointerException is because of null values in below variable in myproject.slingmodels.core.PageImpl
@ScriptVariable
protected com.day.cq.wcm.api.Page currentPage;
@Self
private SlingHttpServletRequest request;
are we missing anything since browser based access is working and not through code