April 26, 2020
Estimated Post Reading Time ~

Exception while calling a Servlet in AEM

Question: I am trying to access a servlet with a doPost method from the JSP and getting the following exception.

Caused by org.apache.sling.api.resource.PersistenceException: Resource at ‘/location/Stores’ is not modifiable.
at rg.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(SlingPropertyValueHandler.java:153)
at org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(ModifyOperation.java:411)
at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:101)


My bundle is built successfully and the resource resolver shows the path as expected and resolves to the given path. Activate method of the servlet is successfully called. However, while trying to give an Ajax call from the jsp it never reaches the doPost method. I tried it both with doPost and doGet. Please help.


Answer: Give your servlet path as /bin/location/Stores or /services/location/Stores which is configured in ‘Apache Sling Servlet Resolver’
If you want, you can add your own Servlet/Script resolver from /system/console/configMgr and your custom resourcePath will be resolved by the servlet resolver


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.