Expand my Community achievements bar.

SOLVED

Exception while calling a Servlet

Avatar

Level 2

Hello,

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 org.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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

3 Replies

Avatar

Level 10

AEM is thinking that request /location/Stores is a resource path, he is unable to think this as request for your servlet, then it tries to alter this path , and fails as it does not exist.

Ensure that your servlet is active or not under /system/console/components.

See this community article as well to check what you are missing: https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Would you mind sharing code snippet of your servlet please?

Avatar

Correct answer by
Level 10

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

Avatar

Level 2

Thanks!! This was really helpful.I tried a customized and did not include anything from the 'Apache Sling Servlet Resolver' which was causing this issue.Thanks a ton!! :) :)