Two similar servlets. One works. The other errors "invalid recursion selector value"

Avatar

Avatar

mpalme1

Avatar

mpalme1

mpalme1

29-12-2020

I have the following servlet that works great

@component(
		service=Servlet.class,
		property= {					
			"sling.servlet.resourceTypes="+"mysite/components/structure/page",
			"sling.servlet.selectors="+"testselector",
			"sling.servlet.extensions="+"json",
			ServletResolverConstants.SLING_SERVLET_METHODS + "=GET"
		}	
	)
public class TestServlet extends SlingSafeMethodsServlet

 

I can call it using jquery ajax on a page like this 

$.ajax({
	type:"GET",
	url: "/_jcr_content.testselector.json",				
	success: function(data){
		console.log("success!")									
	}
});

 

I can also put the full address to the servlet in my browser (if i'm logged into my local aem instance) and get a valid response.

 

But if I create a second servlet that is almost identical like this:

@component(
		service=Servlet.class,
		property= {					
			"sling.servlet.resourceTypes="+"mysite/components/structure/page",
			"sling.servlet.selectors="+"testselectortwo",
			"sling.servlet.extensions="+"json",
			ServletResolverConstants.SLING_SERVLET_METHODS + "=GET"
		}	
	)
public class TestServletTwo extends SlingSafeMethodsServlet

then any calls to TestServletTwo return 400 Bad Request and in the browser, shows the error "Invalid recursion selector value testselectortwo". 

 

Why isn't the second one working?

View Entire Topic

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

04-01-2021

Your error says that the issue is with the selector value "testselectortwo". Try changing it and check if it works.

 

Also, In addition to the below steps mentioned by @shelly-goel, can you please share the log entries once you hit the second servlet?

 

Thanks,

Kiran Vedantam.