Expand my Community achievements bar.

SOLVED

Servlet issue in 6.1 upgrade (from 5.6.1)

Avatar

Level 2

Hi,

I'm working on 5.6.1 to 6.1 upgrade. I'm facing issues with few custom servlets (these servlets are working fine in current 5.6.1).

My servlet looks like 

@Component(label = "The Search Servlet.", description = "Servlet for Search Process", metatype = false, immediate = true) @SlingServlet(generateComponent = false, paths = {"/bin/XXXX/servlet/search"}, extensions = {"html"})public class SearchServlet extends AbstractPostServlet {

.

}

but this servlet status is  'satisfied' in the Felix console. So I have modified the above servlet to

@Component(immediate = true, metatype = false)
@Service(Servlet.class)
@Properties({
    @Property(name = "sling.servlet.paths", value = "/bin/XXXX/servlet/search"),
    @Property(name = "sling.servlet.methods", value = "POST") })
public class SearchServlet extends SlingAllMethodsServlet {

.....

}

now servlet status is 'active' but still I'm seeing the same error  ( and in this case I'm seeing the request in the Felix console 'recent requests').

Error:-

on the page

Error while processing /bin/XXXX/servlet/search

                             

Status

500

Message

org.apache.sling.api.SlingException: Exception during response processing.

Location

/bin/XXXX/servlet/search

Parent Location

/bin/XXXX/servlet

Path

/bin/XXXX/servlet/search

Referer

server:port/content/XXXX/en.html

ChangeLog

<pre></pre>

GO Back

Modified Resource

Parent of Modified Resource

 In the error.log

*ERROR* [10.225.73.55 [1455628447295] POST /bin/XXXX/servlet/search HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing.

javax.jcr.nodetype.ConstraintViolationException: No default node type available for /bin/XXXX

            at org.apache.jackrabbit.oak.util.TreeUtil.addChild(TreeUtil.java:186)

            at org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.addChild(NodeDelegate.java:692)

            at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:296)

            at org.apache.jackrabbit.oak.jcr.session.NodeImpl$5.perform(NodeImpl.java:262)

            at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:202)

            at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112)

            at org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:262)

            at org.apache.jackrabbit.oak.jcr.session.NodeImpl.addNode(NodeImpl.java:247)

            at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.create(JcrResourceProvider.java:567)

Do you have any idea on this?

Thanks in advance for helping on this.

RJ

1 Accepted Solution

Avatar

Correct answer by
Level 10

As @Scott mentioned

Adding only @SlingServlet(paths="/bin/mySearchServlet", methods = "POST", metatype=true) will make the servlet to work even in 6.1: Example: http://adobeaemclub.com/news-component-in-aem-using-guardian-news-api/

Take a look at similar reported issues, it might help you

http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... :- Add name property

View solution in original post

8 Replies

Avatar

Level 10

To rule out JCR issue in your CQ version - try placing the an AEM 6.1 example Servlet  package for testing purposes.

You should get this result: 

This is using Path and posting data to a Sling Servlet. If you can get this working - it will rule out some sort of configuration issue. 

Install the 6.1 Servlet package here: 

https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html

Make sure you install the 6.1 package and then let us know if that works and you get the same result as the above illustration. 

Avatar

Correct answer by
Level 10

As @Scott mentioned

Adding only @SlingServlet(paths="/bin/mySearchServlet", methods = "POST", metatype=true) will make the servlet to work even in 6.1: Example: http://adobeaemclub.com/news-component-in-aem-using-guardian-news-api/

Take a look at similar reported issues, it might help you

http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... :- Add name property

Avatar

Employee Advisor

Have you verified if Sling is resolving your servlet correctly or not - http://localhost:4502/system/console/servletresolver

Avatar

Level 2

Thanks for your response Scott. I have installed and open the page '/content/submitPage.html' result is below screenshot. Do you think any JCR issue?

Sorry I'm able to attach screen shot-

A. Claim Number - fbe3ce61-0390-47b3-9c15-e02d99ad27cc

A.2. Date of Incident:

B2. First Name:

C1. Last Name

D1. Category : Home clim

E1. Address :

F1. City:

G1. Additional Details:

H1. State    Alabama

            Filed by 

Avatar

Community Advisor
        Hi Are you modifying any jcr content using that servlet ? If so can you check ACL on that content

Avatar

Level 10

Yes - looks like something is wrong - the return JSON is parsed and should be Filed by Scott Macdonald (or what ever your first and last name was)

In this example - if you invoke in Chrome - are you seeing a 200 HTTP value or another value? 

Avatar

Level 2

smacdonald2008 wrote...

Yes - looks like something is wrong - the return JSON is parsed and should be Filed by Scott Macdonald (or what ever your first and last name was)

In this example - if you invoke in Chrome - are you seeing a 200 HTTP value or another value? 

 

 

Yeah, status code is 200 and response is {"date":"","firstname":"","address":"","city":"","cat":"Home","details":"","id":"40a4e66a-e90c-4586-8491-87123436f3a4","state":"Alabama","lastname":""}

Avatar

Level 2

Manikumar wrote...

Hi Are you modifying any jcr content using that servlet ? If so can you check ACL on that content

 


Hi ManiKumar, Thanks for your response, no I'm modifying any JCR content in my servlet, it is just 'response.sendRedirect' with some query parameter in the url.