That’s interesting stuff. I made a second service to handle the post. It's 
associated it with a selector and the resourceType "sling/servlet/default” It 
seems to work as I’m intending. Thanks for your help



On Jul 16, 2015, at 11:32 AM, Jason Bailey <[email protected]> wrote:

> I think this may be a combination of things. Including the difference between 
> how GET and POST are handled. 
>  
> I’m referring to the information here: 
> https://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html
>  
> When determining the resource GET uses both the extension and the selectors, 
> the POST operation doesn't. So even though you are defining a selector and 
> extension in the POST servlet and that’s what it’s being assigned to listen 
> to, that’s not representative of what’s being resolved.
>  
> So in the case of your POST:
>  
> You’re performing a POST to 
> /content/michigan-lsa/web-services/en/people/our-staff/cmrockwe.edit.html
> The POST resolution service strips off the extension and the selector which 
> leaves /content/michigan-lsa/web-services/en/people/our-staff/cmrockwe as the 
> identified resource, which has a resource type of 
> ‘company/components/pages/thepage’  The post resolution service then looks 
> for the handler for that resource.
>  
> Meanwhile your POST servlet was created as virtual resource 
> /apps/company/components/pages/thepage/edit.html.POST.servlet which is not 
> the resource it’s looking for. So it ends up with the default POST handler.
>  
> If you created a secondary service which associates your POST with the 
> resourceType of ‘company/components/pages/thepage’  That should map just fine.
>  
> That said, defining POST handlers yourself can end up causing you more 
> headaches then not. As you are overriding one of the core features of the 
> platform.
>  
> -Jason
>  
>  
> From: Christopher Rockwell <[email protected]>
> Sent: Wednesday, July 15, 2015 4:42 PM
> To: [email protected]
> Subject: Re: SlingServlet SO Question
>  
> I think it's the later case you mentioned. The matching property would be 
> under the child jrc:content node. I think my doPost would handle this if it 
> ran. SlingPostServlet has a 500 since the property is not on this node. But I 
> might be misinterpreting the error messages...
>  
> 
>  
> 15.07.2015 16:18:35.128 *ERROR* [0:0:0:0:0:0:0:1 [1436991515125] POST 
> /content/michigan-lsa/web-services/en/people/our-staff/cmrockwe.edit.html 
> HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation 
> Exception during response processing.
> javax.jcr.nodetype.ConstraintViolationException: No matching property 
> definition: firstName = Chris
> at 
> org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate.setProperty(NodeDelegate.java:522)
> at 
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1308)
> at 
> org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.perform(NodeImpl.java:1297)
> at 
> org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:294)
> at org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:113)
> at 
> org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1297)
> at 
> org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:422)
> at 
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.store(SlingPropertyValueHandler.java:592)
> at 
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setPropertyAsIs(SlingPropertyValueHandler.java:305)
> at 
> org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(SlingPropertyValueHandler.java:159)
> 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)
> at 
> org.apache.sling.servlets.post.AbstractPostOperation.run(AbstractPostOperation.java:92)
> at 
> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:199)
> at 
> org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)
> at 
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
> at 
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
> at 
> org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:511)
> at 
> org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)
> at 
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>  
>  
> 
>  
> On Jul 15, 2015, at 4:28 PM, Jason Bailey <[email protected]> wrote:
> 
> 
> The 500 response is a server error, so it's not just handling it off to the 
> default POST handler, but it's encountering a problem when it does it. So if 
> you take a look at your log files while you post, or the content of the 500 
> message itself it should provide some additional details as to the problem 
> that you are encountering. Or is it just yelling at you because it's trying 
> to write to that path?
> 
> 
> 
> -----Original Message-----
> From: Christopher Rockwell [mailto:[email protected]] 
> Sent: Wednesday, July 15, 2015 4:13 PM
> To: [email protected]
> Subject: Re: SlingServlet SO Question
> 
> Request 
> URL:http://localhost:4502/content/michigan-lsa/web-services/en/people/our-staff/cmrockwe.edit.html
> Request Method:POST
> Status Code:500 Server Error
> 
> Hi Jason. I copied the URL information from Chrome Tools' Network tab. Let me 
> know if you wanted something else. Thanks!
> 
> 
> 
> 
> 
> 
> On Jul 15, 2015, at 3:42 PM, Jason Bailey <[email protected]> wrote:
> 
> 
> Hi Chris,
> 
> Can you capture what the post url looks like? 
> 
> -Jason
> 
> 
> -----Original Message-----
> From: Christopher Rockwell [mailto:[email protected]] 
> Sent: Wednesday, July 15, 2015 2:08 PM
> To: [email protected]
> Subject: SlingServlet SO Question
> 
> Hi all.  I'm having trouble with a servlet that extends 
> SlingAllMethodsServlet. I've posted about the problem 
> ...http://stackoverflow.com/questions/31437806/custom-sling-post-servlet-not-working
>  Any input would be much appreciated.
> 
> Thanks
> Chris Rockwell
> LSA CMS/Web Services 
> [email protected]
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>  
>  

Reply via email to