Invalid recursion selector value 'autoComplete' | Community
Skip to main content
Level 2
October 16, 2015
Solved

Invalid recursion selector value 'autoComplete'

  • October 16, 2015
  • 2 replies
  • 3587 views

Hi,

I registered a Sling-Servlet to generate JSON when a resource of the resource type "my/resource/type" is called with the selector "autoComplete" and the extension "json":

@Service @Component() @Properties(value = { @Property(name = "sling.servlet.resourceTypes", value = "my/resource/type"), @Property(name = "sling.servlet.selectors", value = { "autoComplete" }), @Property(name = "sling.servlet.extensions", value = { "json" }), @Property(name = "sling.servlet.methods", value = "GET") })

When I call: http://localhost:4502/content/xyz/global/corporate/en/search.autoComplete.json?searchText=ro        

(which resource is of the correct resource type) I get the following exception:

Invalid recursion selector value 'autoComplete' Cannot serve request to /content/xyz/global/corporate/en/search.autoComplete.json in org.apache.sling.servlets.get.DefaultGetServlet 0 (2015-01-07 17:14:13) TIMER_START{Request Processing} 0 (2015-01-07 17:14:13) COMMENT timer_end format is {<elapsed msec>,<timer name>} <optional message> 0 (2015-01-07 17:14:13) LOG Method=GET, PathInfo=/content/xyz/global/corporate/en/search.autoComplete.json 0 (2015-01-07 17:14:13) TIMER_START{ResourceResolution} 0 (2015-01-07 17:14:13) TIMER_END{0,ResourceResolution} URI=/content/xyz/global/corporate/en/search.autoComplete.json resolves to Resource=JcrNodeResource, type=cq:Page, superType=null, path=/content/xyz/global/corporate/en/search 0 (2015-01-07 17:14:13) LOG Resource Path Info: SlingRequestPathInfo: path='/content/xyz/global/corporate/en/search', selectorString='autoComplete', extension='json', suffix='null' 0 (2015-01-07 17:14:13) TIMER_START{ServletResolution} 0 (2015-01-07 17:14:13) TIMER_START{resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/xyz/global/corporate/en/search)} 0 (2015-01-07 17:14:13) TIMER_END{0,resolveServlet(JcrNodeResource, type=cq:Page, superType=null, path=/content/xyz/global/corporate/en/search)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet 0 (2015-01-07 17:14:13) TIMER_END{0,ServletResolution} URI=/content/xyz/global/corporate/en/search.autoComplete.json handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet 0 (2015-01-07 17:14:13) LOG Applying Requestfilters 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl 0 (2015-01-07 17:14:13) LOG Calling filter: org.apache.sling.bgservlets.impl.BackgroundServletStarterFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.cq.dam.s7imaging.impl.auth.MemoryTokenAuthHandler 0 (2015-01-07 17:14:13) LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter 0 (2015-01-07 17:14:13) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.designimporter.CanvasPageDeleteRequestFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.cq.history.impl.HistoryRequestFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.theme.impl.ThemeResolverFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet 0 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter 0 (2015-01-07 17:14:13) LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter 0 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter 1 (2015-01-07 17:14:13) LOG RedirectFilter did not redirect (request extension does not match) 1 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.core.impl.warp.TimeWarpFilter 1 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl 1 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.cq.social.commons.security.SaferSlingPostServlet 1 (2015-01-07 17:14:13) LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl 1 (2015-01-07 17:14:13) LOG Applying Componentfilters 1 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter 1 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter 1 (2015-01-07 17:14:13) LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter 1 (2015-01-07 17:14:13) TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0} 1 (2015-01-07 17:14:13) LOG Using org.apache.sling.servlets.get.impl.helpers.JsonRendererServlet to render for extension=json 1 (2015-01-07 17:14:13) LOG Applying Error filters 1 (2015-01-07 17:14:13) LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter 1 (2015-01-07 17:14:13) TIMER_START{handleError:status=400} 3 (2015-01-07 17:14:13) TIMER_END{2,handleError:status=400} Using handler /libs/sling/servlet/errorhandler/default.jsp 8 (2015-01-07 17:14:13) LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html],order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobile: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=mobiledebug, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobiledebug: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=contentsync, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-contentsync: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), serializer=Config(type=htmlwriter, config={}))} 8 (2015-01-07 17:14:13) TIMER_END{8,Request Processing} Dumping SlingRequestProgressTracker Entries 11 (2015-01-07 17:14:13) TIMER_END{10,handleError:status=400} Error handler finished 11 (2015-01-07 17:14:13) TIMER_END{10,org.apache.sling.servlets.get.DefaultGetServlet#0} 11 (2015-01-07 17:14:13) TIMER_END{11,Request Processing} Request Processing

For some reason it seems that my "AutoCompleteControllerServlet" is never called. The Problem seems to be the "json" extension. As soon as I specify this the DefaultGetServlet seems to handle the request.

When I specify "html" as the extension my Servlet is called but the following HTML comment is appended to the JSON response generated in my Servlet, which renders the JSON invalid.

<!--cq{"decorated":false,"type":"xyz/pages/search","path":"/content/xyz/global/corporate/en/search/jcr:content","selectors":"autoComplete","servlet":"AutoCompleteControllerServlet","totalTime":13,"selfTime":13}-->

1. Why isn't my servlet called when I specify "json" as extension?

2. Is there a way to tell CQ not to add the HTML comment when I specify "html" as extension?

To use the json extension would be my prefered solution.

Any hint to get regarding this problem is appreciated,

Ronald

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Sham_HC

HI Ronald,

Have [1] handy always.

  /content/xyz/global/corporate/en/search is of type page your servlet never pickup.  If needs to pickedup you need to write proxy.jsp   Instead using /content/xyz/global/corporate/en/search/jcr:content/<component node name which of type  my/resource/type>.autoComplete.json?searchText=ro will work.

[1]  http://dev.day.com/content/ddc/blog/2008/07/cheatsheet.html

Thanks,

Sham

tweet: adobe_sham

2 replies

Sham_HC
Sham_HCAccepted solution
Level 10
October 16, 2015

HI Ronald,

Have [1] handy always.

  /content/xyz/global/corporate/en/search is of type page your servlet never pickup.  If needs to pickedup you need to write proxy.jsp   Instead using /content/xyz/global/corporate/en/search/jcr:content/<component node name which of type  my/resource/type>.autoComplete.json?searchText=ro will work.

[1]  http://dev.day.com/content/ddc/blog/2008/07/cheatsheet.html

Thanks,

Sham

tweet: adobe_sham

Level 2
October 16, 2015

Hi Sham,

thanks a million for your answer and also for reminding me of the Sling Script Resolution Cheetsheet.

You are right: The resource "/content/xyz/global/corporate/en/search" does not have a resource type but only has the "jcr:primaryType" of "cq:page" whereas "/content/xyz/global/corporate/en/search/jcr:content" is of the resource type "my/resource/type".

Therefore when I call "http://localhost:4502/content/xyz/global/corporate/en/search/jcr:content.autoComplete.json?searchText=ro" everything works like a charm.

Thanks again,

Ronald