You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Antonio Sanso <as...@adobe.com> on 2012/11/19 15:49:17 UTC

SlingPostServlet

Hi *,

lately I have been heavily using the SlingPostServlet and I have noticed a behavior different than expected.
Let me describe it.:

- In a fresh instance of Sling create a sling:folder node named 'one'
- execute this curl call 

curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start localhost:8080/apps/one/two/three

as expected the response is 201 as in [0].

So far so good.
But if I change the first step creating a nt:folder rather than a sling:folder I have back a 500 as in [1] with stacktrace:

Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
	... 40 more

see [2] for the complete stacktrace.
Now while I might understand the reason (nt:folder node definition) I think that it would be nice if the SlingPostServlet would handle this case seamlessly.

WDYT?

Regards

Antonio

[0]
<html>
<head>
    <title>Content created /apps/one/two/three</title>
</head>
    <body>
    <h1>Content created /apps/one/two/three</h1>
    <table>
        <tbody>
            <tr>
                <td>Status</td>
                <td><div id="Status">201</div></td>
            </tr>
            <tr>
                <td>Message</td>
                <td><div id="Message">Created</div></td>
            </tr>
            <tr>
                <td>Location</td>
                <td><a href="/apps/one/two/three" id="Location">/apps/one/two/three</a></td>
            </tr>
            <tr>
                <td>Parent Location</td>
                <td><a href="/apps/one/two" id="ParentLocation">/apps/one/two</a></td>
            </tr>
            <tr>
                <td>Path</td>
                <td><div id="Path">/apps/one/two/three</div></td>
            </tr>
            <tr>
                <td>Referer</td>
                <td><a href="" id="Referer"></a></td>
            </tr>
            <tr>
                <td>ChangeLog</td>
                <td><div id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
            </tr>
        </tbody>
    </table>
    <p><a href="">Go Back</a></p>
    <p><a href="/apps/one/two/three">Modified Resource</a></p>
    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
    </body>

[1]  <html>
<head>
    <title>Error while processing /apps/one/two/three</title>
</head>
    <body>
    <h1>Error while processing /apps/one/two/three</h1>
    <table>
        <tbody>
            <tr>
                <td>Status</td>
                <td><div id="Status">500</div></td>
            </tr>
            <tr>
                <td>Message</td>
                <td><div id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node definition for two found in node /apps/one</div></td>
            </tr>
            <tr>
                <td>Location</td>
                <td><a href="/apps/one/two/three" id="Location">/apps/one/two/three</a></td>
            </tr>
            <tr>
                <td>Parent Location</td>
                <td><a href="/apps/one/two" id="ParentLocation">/apps/one/two</a></td>
            </tr>
            <tr>
                <td>Path</td>
                <td><div id="Path">/apps/one/two/three</div></td>
            </tr>
            <tr>
                <td>Referer</td>
                <td><a href="" id="Referer"></a></td>
            </tr>
            <tr>
                <td>ChangeLog</td>
                <td><div id="ChangeLog"><pre></pre></div></td>
            </tr>
        </tbody>
    </table>
    <p><a href="">Go Back</a></p>
    <p><a href="/apps/one/two/three">Modified Resource</a></p>
    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
    </body>

[2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST /apps/one/two/three HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing. javax.jcr.nodetype.ConstraintViolationException: No child node definition for two found in node /apps/one
	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
	at org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
	at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
	at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
	at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
	at org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
	at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
	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:529)
	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
	at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
	at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
	at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
	at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
	at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
	at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
	at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
	at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
	at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
	at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
	at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
	... 40 more

Re: SlingPostServlet

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 20.11.2012, at 11:32, Antonio Sanso <as...@adobe.com> wrote:

> Index: src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
> ===================================================================
> --- src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java   (revision 1344135)
> +++ src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java   (working copy)
> @@ -491,7 +491,11 @@
>                     if (nodeType != null) {
>                         node = node.addNode(name, nodeType);
>                     } else {
> -                        node = node.addNode(name);
> +                       try{
> +                               node = node.addNode(name);
> +                       }catch(ConstraintViolationException cve){
> +                               node = node.addNode(name,startingNode.getPrimaryNodeType().getName());
> +                        }

-1

There is no automatic solution to this. You have to think about your content model and specify the type for every node as part of your request if there is no primary child node.

Cheers,
Alex

Re: SlingPostServlet

Posted by Carsten Ziegeler <cz...@apache.org>.
Just for the record, your patch was against an old version :)
The addNode stuff is now in the jcr resource provider.

Regards
Carsten

2012/11/20 Antonio Sanso <as...@adobe.com>:
>
> On Nov 20, 2012, at 1:25 PM, Bertrand Delacretaz wrote:
>
>
>> On Tue, Nov 20, 2012 at 11:39 AM, Felix Meschberger <fm...@adobe.com> wrote:
>>> ...Rather I would prefer failing to create intermediate nodes if no primary type is specified. But this
>>> would break backwards compatibility....
>>
>> I'm not sure if we already allow specifying the node type for
>> intermediate nodes, but that might be helpful, as in "create /a/b/c/d,
>> including intermediate nodes as needed, using nt:folder for all node
>> types".
>
> +1
>
> as said my patch was just an attempt to develop the heuristic mentioned yesterday, namely "inheriting the node types from the closest existing ancestor,".
> Should this not be good we might agree on a different one.
>
> Regards
>
> Antonio
>
>
>>
>> -Bertrand
>



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: SlingPostServlet

Posted by Antonio Sanso <as...@adobe.com>.
On Nov 20, 2012, at 1:25 PM, Bertrand Delacretaz wrote:


> On Tue, Nov 20, 2012 at 11:39 AM, Felix Meschberger <fm...@adobe.com> wrote:
>> ...Rather I would prefer failing to create intermediate nodes if no primary type is specified. But this
>> would break backwards compatibility....
> 
> I'm not sure if we already allow specifying the node type for
> intermediate nodes, but that might be helpful, as in "create /a/b/c/d,
> including intermediate nodes as needed, using nt:folder for all node
> types".

+1

as said my patch was just an attempt to develop the heuristic mentioned yesterday, namely "inheriting the node types from the closest existing ancestor,".
Should this not be good we might agree on a different one. 

Regards

Antonio


> 
> -Bertrand


Re: SlingPostServlet

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Tue, Nov 20, 2012 at 11:39 AM, Felix Meschberger <fm...@adobe.com> wrote:
> ...Rather I would prefer failing to create intermediate nodes if no primary type is specified. But this
> would break backwards compatibility....

I'm not sure if we already allow specifying the node type for
intermediate nodes, but that might be helpful, as in "create /a/b/c/d,
including intermediate nodes as needed, using nt:folder for all node
types".

-Bertrand

Re: SlingPostServlet

Posted by Felix Meschberger <fm...@adobe.com>.
Hi

No, I don't think so.

Rather I would prefer failing to create intermediate nodes if no primary type is specified. But this would break backwards compatibility.

Regards
Felix

Am 20.11.2012 um 11:32 schrieb Antonio Sanso:

> Hi *,
> 
> should we want to implement the heuristic mentioned from Felix the patch might be  as simple as
> 
> Index: src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
> ===================================================================
> --- src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java   (revision 1344135)
> +++ src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java   (working copy)
> @@ -491,7 +491,11 @@
>                     if (nodeType != null) {
>                         node = node.addNode(name, nodeType);
>                     } else {
> -                        node = node.addNode(name);
> +                       try{
> +                               node = node.addNode(name);
> +                       }catch(ConstraintViolationException cve){
> +                               node = node.addNode(name,startingNode.getPrimaryNodeType().getName());
> +                        }
> 
>                     }
>                 } catch (VersionException e) {
> 
> WDYT?
> 
> Regards
> 
> Antonio
> 
> On Nov 19, 2012, at 4:22 PM, Antonio Sanso wrote:
> 
>> Hi Justin,
>> 
>> 
>> On Nov 19, 2012, at 4:00 PM, Justin Edelson wrote:
>> 
>>> Antonio-
>>> This is because there's no default node type for child nodes of nt:folder.
>>> I'd be curious how you think this could be handled automatically by the
>>> PostServlet.
>> 
>> he he  I do not have a specific idea in mind (just yet). But coming back to my original question if it would be nice to deal with it seamlessly we might come up with something (e.g. what described by Felix).
>> 
>> 
>> Regards
>> 
>> Antonio
>> 
>>> As far as I can tell, there's no heuristic which could be
>>> applied.
>>> 
>>> Regards,
>>> Justin
>>> 
>>> 
>>> On Mon, Nov 19, 2012 at 9:49 AM, Antonio Sanso <as...@adobe.com> wrote:
>>> 
>>>> Hi *,
>>>> 
>>>> lately I have been heavily using the SlingPostServlet and I have noticed a
>>>> behavior different than expected.
>>>> Let me describe it.:
>>>> 
>>>> - In a fresh instance of Sling create a sling:folder node named 'one'
>>>> - execute this curl call
>>>> 
>>>> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>>>> localhost:8080/apps/one/two/three
>>>> 
>>>> as expected the response is 201 as in [0].
>>>> 
>>>> So far so good.
>>>> But if I change the first step creating a nt:folder rather than a
>>>> sling:folder I have back a 500 as in [1] with stacktrace:
>>>> 
>>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>>>> child node definition found for {}two
>>>>      at
>>>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>>      at
>>>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>>      ... 40 more
>>>> 
>>>> see [2] for the complete stacktrace.
>>>> Now while I might understand the reason (nt:folder node definition) I
>>>> think that it would be nice if the SlingPostServlet would handle this case
>>>> seamlessly.
>>>> 
>>>> WDYT?
>>>> 
>>>> Regards
>>>> 
>>>> Antonio
>>>> 
>>>> [0]
>>>> <html>
>>>> <head>
>>>>  <title>Content created /apps/one/two/three</title>
>>>> </head>
>>>>  <body>
>>>>  <h1>Content created /apps/one/two/three</h1>
>>>>  <table>
>>>>      <tbody>
>>>>          <tr>
>>>>              <td>Status</td>
>>>>              <td><div id="Status">201</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Message</td>
>>>>              <td><div id="Message">Created</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Location</td>
>>>>              <td><a href="/apps/one/two/three"
>>>> id="Location">/apps/one/two/three</a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Parent Location</td>
>>>>              <td><a href="/apps/one/two"
>>>> id="ParentLocation">/apps/one/two</a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Path</td>
>>>>              <td><div id="Path">/apps/one/two/three</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Referer</td>
>>>>              <td><a href="" id="Referer"></a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>ChangeLog</td>
>>>>              <td><div
>>>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>>>>          </tr>
>>>>      </tbody>
>>>>  </table>
>>>>  <p><a href="">Go Back</a></p>
>>>>  <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>>  <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>>  </body>
>>>> 
>>>> [1]  <html>
>>>> <head>
>>>>  <title>Error while processing /apps/one/two/three</title>
>>>> </head>
>>>>  <body>
>>>>  <h1>Error while processing /apps/one/two/three</h1>
>>>>  <table>
>>>>      <tbody>
>>>>          <tr>
>>>>              <td>Status</td>
>>>>              <td><div id="Status">500</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Message</td>
>>>>              <td><div
>>>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>>>> definition for two found in node /apps/one</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Location</td>
>>>>              <td><a href="/apps/one/two/three"
>>>> id="Location">/apps/one/two/three</a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Parent Location</td>
>>>>              <td><a href="/apps/one/two"
>>>> id="ParentLocation">/apps/one/two</a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Path</td>
>>>>              <td><div id="Path">/apps/one/two/three</div></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>Referer</td>
>>>>              <td><a href="" id="Referer"></a></td>
>>>>          </tr>
>>>>          <tr>
>>>>              <td>ChangeLog</td>
>>>>              <td><div id="ChangeLog"><pre></pre></div></td>
>>>>          </tr>
>>>>      </tbody>
>>>>  </table>
>>>>  <p><a href="">Go Back</a></p>
>>>>  <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>>  <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>>  </body>
>>>> 
>>>> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>>>> /apps/one/two/three HTTP/1.1]
>>>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>>>> during response processing.
>>>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>>>> for two found in node /apps/one
>>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>>>>      at
>>>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>>>>      at
>>>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>>>>      at
>>>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>>>>      at
>>>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>>>>      at
>>>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>>>>      at
>>>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>>>>      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:529)
>>>>      at
>>>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>>>>      at
>>>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>>>>      at
>>>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>>>>      at
>>>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>>>>      at
>>>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>>>>      at
>>>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>>>>      at
>>>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>>>>      at
>>>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>>>      at
>>>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>>>      at
>>>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>>>      at
>>>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>>>      at
>>>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>>>      at
>>>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>>>      at
>>>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>>>      at
>>>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>>      at
>>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>>>      at
>>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>>>      at
>>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>>>      at
>>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>>      at
>>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>>      at org.mortbay.jetty.Server.handle(Server.java:326)
>>>>      at
>>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>>>      at
>>>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>>>      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>>>      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>>      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>>      at
>>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>>>      at
>>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>>>> child node definition found for {}two
>>>>      at
>>>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>>      at
>>>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>>      ... 40 more
>> 
> 


Re: SlingPostServlet

Posted by Antonio Sanso <as...@adobe.com>.
Hi *,

should we want to implement the heuristic mentioned from Felix the patch might be  as simple as

Index: src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
===================================================================
--- src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java	(revision 1344135)
+++ src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java	(working copy)
@@ -491,7 +491,11 @@
                     if (nodeType != null) {
                         node = node.addNode(name, nodeType);
                     } else {
-                        node = node.addNode(name);
+                    	try{
+                    		node = node.addNode(name);
+                    	}catch(ConstraintViolationException cve){
+                        	node = node.addNode(name,startingNode.getPrimaryNodeType().getName());
+                        }
 
                     }
                 } catch (VersionException e) {

WDYT?

Regards

Antonio

On Nov 19, 2012, at 4:22 PM, Antonio Sanso wrote:

> Hi Justin,
> 
> 
> On Nov 19, 2012, at 4:00 PM, Justin Edelson wrote:
> 
>> Antonio-
>> This is because there's no default node type for child nodes of nt:folder.
>> I'd be curious how you think this could be handled automatically by the
>> PostServlet.
> 
> he he  I do not have a specific idea in mind (just yet). But coming back to my original question if it would be nice to deal with it seamlessly we might come up with something (e.g. what described by Felix).
> 
> 
> Regards
> 
> Antonio
> 
>> As far as I can tell, there's no heuristic which could be
>> applied.
>> 
>> Regards,
>> Justin
>> 
>> 
>> On Mon, Nov 19, 2012 at 9:49 AM, Antonio Sanso <as...@adobe.com> wrote:
>> 
>>> Hi *,
>>> 
>>> lately I have been heavily using the SlingPostServlet and I have noticed a
>>> behavior different than expected.
>>> Let me describe it.:
>>> 
>>> - In a fresh instance of Sling create a sling:folder node named 'one'
>>> - execute this curl call
>>> 
>>> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>>> localhost:8080/apps/one/two/three
>>> 
>>> as expected the response is 201 as in [0].
>>> 
>>> So far so good.
>>> But if I change the first step creating a nt:folder rather than a
>>> sling:folder I have back a 500 as in [1] with stacktrace:
>>> 
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>>> child node definition found for {}two
>>>       at
>>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>       at
>>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>       ... 40 more
>>> 
>>> see [2] for the complete stacktrace.
>>> Now while I might understand the reason (nt:folder node definition) I
>>> think that it would be nice if the SlingPostServlet would handle this case
>>> seamlessly.
>>> 
>>> WDYT?
>>> 
>>> Regards
>>> 
>>> Antonio
>>> 
>>> [0]
>>> <html>
>>> <head>
>>>   <title>Content created /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Content created /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">201</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div id="Message">Created</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div
>>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [1]  <html>
>>> <head>
>>>   <title>Error while processing /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Error while processing /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">500</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div
>>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>>> definition for two found in node /apps/one</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div id="ChangeLog"><pre></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>>> /apps/one/two/three HTTP/1.1]
>>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>>> during response processing.
>>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>>> for two found in node /apps/one
>>>       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>>>       at
>>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>>>       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>>>       at
>>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>>>       at
>>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>>>       at
>>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>>>       at
>>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>>>       at
>>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>>>       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:529)
>>>       at
>>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>>>       at
>>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>>>       at
>>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>>>       at
>>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>>>       at
>>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>>>       at
>>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>>>       at
>>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>>>       at
>>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>>       at
>>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>>       at
>>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>>       at
>>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>>       at
>>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>>       at
>>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>>       at
>>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>>       at
>>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>       at
>>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>>       at
>>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>>       at
>>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>>       at
>>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>       at
>>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>       at org.mortbay.jetty.Server.handle(Server.java:326)
>>>       at
>>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>>       at
>>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>>       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>>       at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>       at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>       at
>>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>>       at
>>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>>> child node definition found for {}two
>>>       at
>>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>       at
>>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>       ... 40 more
> 


Re: SlingPostServlet

Posted by Antonio Sanso <as...@adobe.com>.
Hi Justin,


On Nov 19, 2012, at 4:00 PM, Justin Edelson wrote:

> Antonio-
> This is because there's no default node type for child nodes of nt:folder.
> I'd be curious how you think this could be handled automatically by the
> PostServlet.

he he  I do not have a specific idea in mind (just yet). But coming back to my original question if it would be nice to deal with it seamlessly we might come up with something (e.g. what described by Felix).


Regards

Antonio

> As far as I can tell, there's no heuristic which could be
> applied.
> 
> Regards,
> Justin
> 
> 
> On Mon, Nov 19, 2012 at 9:49 AM, Antonio Sanso <as...@adobe.com> wrote:
> 
>> Hi *,
>> 
>> lately I have been heavily using the SlingPostServlet and I have noticed a
>> behavior different than expected.
>> Let me describe it.:
>> 
>> - In a fresh instance of Sling create a sling:folder node named 'one'
>> - execute this curl call
>> 
>> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>> localhost:8080/apps/one/two/three
>> 
>> as expected the response is 201 as in [0].
>> 
>> So far so good.
>> But if I change the first step creating a nt:folder rather than a
>> sling:folder I have back a 500 as in [1] with stacktrace:
>> 
>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>        at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>        at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>        at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>        ... 40 more
>> 
>> see [2] for the complete stacktrace.
>> Now while I might understand the reason (nt:folder node definition) I
>> think that it would be nice if the SlingPostServlet would handle this case
>> seamlessly.
>> 
>> WDYT?
>> 
>> Regards
>> 
>> Antonio
>> 
>> [0]
>> <html>
>> <head>
>>    <title>Content created /apps/one/two/three</title>
>> </head>
>>    <body>
>>    <h1>Content created /apps/one/two/three</h1>
>>    <table>
>>        <tbody>
>>            <tr>
>>                <td>Status</td>
>>                <td><div id="Status">201</div></td>
>>            </tr>
>>            <tr>
>>                <td>Message</td>
>>                <td><div id="Message">Created</div></td>
>>            </tr>
>>            <tr>
>>                <td>Location</td>
>>                <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>            </tr>
>>            <tr>
>>                <td>Parent Location</td>
>>                <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>            </tr>
>>            <tr>
>>                <td>Path</td>
>>                <td><div id="Path">/apps/one/two/three</div></td>
>>            </tr>
>>            <tr>
>>                <td>Referer</td>
>>                <td><a href="" id="Referer"></a></td>
>>            </tr>
>>            <tr>
>>                <td>ChangeLog</td>
>>                <td><div
>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>>            </tr>
>>        </tbody>
>>    </table>
>>    <p><a href="">Go Back</a></p>
>>    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>    </body>
>> 
>> [1]  <html>
>> <head>
>>    <title>Error while processing /apps/one/two/three</title>
>> </head>
>>    <body>
>>    <h1>Error while processing /apps/one/two/three</h1>
>>    <table>
>>        <tbody>
>>            <tr>
>>                <td>Status</td>
>>                <td><div id="Status">500</div></td>
>>            </tr>
>>            <tr>
>>                <td>Message</td>
>>                <td><div
>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>> definition for two found in node /apps/one</div></td>
>>            </tr>
>>            <tr>
>>                <td>Location</td>
>>                <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>            </tr>
>>            <tr>
>>                <td>Parent Location</td>
>>                <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>            </tr>
>>            <tr>
>>                <td>Path</td>
>>                <td><div id="Path">/apps/one/two/three</div></td>
>>            </tr>
>>            <tr>
>>                <td>Referer</td>
>>                <td><a href="" id="Referer"></a></td>
>>            </tr>
>>            <tr>
>>                <td>ChangeLog</td>
>>                <td><div id="ChangeLog"><pre></pre></div></td>
>>            </tr>
>>        </tbody>
>>    </table>
>>    <p><a href="">Go Back</a></p>
>>    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>    </body>
>> 
>> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>> /apps/one/two/three HTTP/1.1]
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>> during response processing.
>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>> for two found in node /apps/one
>>        at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>>        at
>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>>        at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>>        at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>>        at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>>        at
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>>        at
>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>>        at
>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>>        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:529)
>>        at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>>        at
>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>>        at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>>        at
>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>>        at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>>        at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>>        at
>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>>        at
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>        at
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>        at
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>        at
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>        at
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>        at
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>        at
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>        at
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>        at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>        at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>        at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>        at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>        at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>        at org.mortbay.jetty.Server.handle(Server.java:326)
>>        at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>        at
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>        at
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>        at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>        at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>        at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>        at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>        ... 40 more


Re: SlingPostServlet

Posted by Justin Edelson <ju...@justinedelson.com>.
Antonio-
This is because there's no default node type for child nodes of nt:folder.
I'd be curious how you think this could be handled automatically by the
PostServlet. As far as I can tell, there's no heuristic which could be
applied.

Regards,
Justin


On Mon, Nov 19, 2012 at 9:49 AM, Antonio Sanso <as...@adobe.com> wrote:

> Hi *,
>
> lately I have been heavily using the SlingPostServlet and I have noticed a
> behavior different than expected.
> Let me describe it.:
>
> - In a fresh instance of Sling create a sling:folder node named 'one'
> - execute this curl call
>
> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
> localhost:8080/apps/one/two/three
>
> as expected the response is 201 as in [0].
>
> So far so good.
> But if I change the first step creating a nt:folder rather than a
> sling:folder I have back a 500 as in [1] with stacktrace:
>
> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
> child node definition found for {}two
>         at
> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>         at
> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>         at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>         ... 40 more
>
> see [2] for the complete stacktrace.
> Now while I might understand the reason (nt:folder node definition) I
> think that it would be nice if the SlingPostServlet would handle this case
> seamlessly.
>
> WDYT?
>
> Regards
>
> Antonio
>
> [0]
> <html>
> <head>
>     <title>Content created /apps/one/two/three</title>
> </head>
>     <body>
>     <h1>Content created /apps/one/two/three</h1>
>     <table>
>         <tbody>
>             <tr>
>                 <td>Status</td>
>                 <td><div id="Status">201</div></td>
>             </tr>
>             <tr>
>                 <td>Message</td>
>                 <td><div id="Message">Created</div></td>
>             </tr>
>             <tr>
>                 <td>Location</td>
>                 <td><a href="/apps/one/two/three"
> id="Location">/apps/one/two/three</a></td>
>             </tr>
>             <tr>
>                 <td>Parent Location</td>
>                 <td><a href="/apps/one/two"
> id="ParentLocation">/apps/one/two</a></td>
>             </tr>
>             <tr>
>                 <td>Path</td>
>                 <td><div id="Path">/apps/one/two/three</div></td>
>             </tr>
>             <tr>
>                 <td>Referer</td>
>                 <td><a href="" id="Referer"></a></td>
>             </tr>
>             <tr>
>                 <td>ChangeLog</td>
>                 <td><div
> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>             </tr>
>         </tbody>
>     </table>
>     <p><a href="">Go Back</a></p>
>     <p><a href="/apps/one/two/three">Modified Resource</a></p>
>     <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>     </body>
>
> [1]  <html>
> <head>
>     <title>Error while processing /apps/one/two/three</title>
> </head>
>     <body>
>     <h1>Error while processing /apps/one/two/three</h1>
>     <table>
>         <tbody>
>             <tr>
>                 <td>Status</td>
>                 <td><div id="Status">500</div></td>
>             </tr>
>             <tr>
>                 <td>Message</td>
>                 <td><div
> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
> definition for two found in node /apps/one</div></td>
>             </tr>
>             <tr>
>                 <td>Location</td>
>                 <td><a href="/apps/one/two/three"
> id="Location">/apps/one/two/three</a></td>
>             </tr>
>             <tr>
>                 <td>Parent Location</td>
>                 <td><a href="/apps/one/two"
> id="ParentLocation">/apps/one/two</a></td>
>             </tr>
>             <tr>
>                 <td>Path</td>
>                 <td><div id="Path">/apps/one/two/three</div></td>
>             </tr>
>             <tr>
>                 <td>Referer</td>
>                 <td><a href="" id="Referer"></a></td>
>             </tr>
>             <tr>
>                 <td>ChangeLog</td>
>                 <td><div id="ChangeLog"><pre></pre></div></td>
>             </tr>
>         </tbody>
>     </table>
>     <p><a href="">Go Back</a></p>
>     <p><a href="/apps/one/two/three">Modified Resource</a></p>
>     <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>     </body>
>
> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
> /apps/one/two/three HTTP/1.1]
> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
> during response processing.
> javax.jcr.nodetype.ConstraintViolationException: No child node definition
> for two found in node /apps/one
>         at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>         at
> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>         at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>         at
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>         at
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>         at
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>         at
> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>         at
> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>         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:529)
>         at
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>         at
> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>         at
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>         at
> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>         at
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>         at
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>         at
> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>         at
> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>         at
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>         at
> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>         at
> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>         at
> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>         at
> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>         at
> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>         at
> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>         at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>         at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>         at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>         at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>         at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>         at org.mortbay.jetty.Server.handle(Server.java:326)
>         at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>         at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>         at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>         at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>         at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>         at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>         at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
> child node definition found for {}two
>         at
> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>         at
> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>         at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>         ... 40 more

Re: SlingPostServlet

Posted by Antonio Sanso <as...@adobe.com>.
Hi Felix,

apologies for the bad choice of the name but start is actually a file (nt:file) rather than a property.
I do experience the same behavior described from Justin below (single argument addNode).
Should the logic you described be applied is the nearest ancestor node type still nt:folder?

Regards

Antonio

On Nov 19, 2012, at 4:07 PM, Justin Edelson wrote:

> Hi Felix,
> 
> On Mon, Nov 19, 2012 at 9:59 AM, Felix Meschberger <fm...@adobe.com>wrote:
> 
>> Hi
>> 
>> The problem here is, that Sling has to create two nodes one/two and
>> one/two/three to place the start property in node three. Your request is
>> underspecified in that no node types are defined for nodes two and three.
>> 
>> There are two options, basically: Sling could fail (as WebDAV does)
>> because two and three are missing and intermediate nodes would be created.
>> Or Sling could somehow create intermediate nodes. We decided to go for the
>> second option.
>> 
>> Now, what node types do we apply ? We decided to go for inheriting the
>> node types from the closest existing ancestor, which is one in this case.
>> 
> 
> Is this new behavior? At least in the last release before the recent CRUD
> additions, if there was no node type in the request parameters, the single
> argument addNode() was used, which (based on the JCR spec) uses the child
> node definition from the node type definition. See line 494 of
> https://fisheye6.atlassian.com/browse/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?r=1146769
> 
> Justin
> 
> 
>> 
>> You can probably easily "fix" this by adding
>> "-Fjcr:primaryType=nt:unstructured" (or any type accepting a start
>> property)to your curl request. In this case the node type of node three is
>> defined and only the type of two would be inherited from one.
>> 
>> Regards
>> Felix
>> 
>> Am 19.11.2012 um 15:49 schrieb Antonio Sanso:
>> 
>>> Hi *,
>>> 
>>> lately I have been heavily using the SlingPostServlet and I have noticed
>> a behavior different than expected.
>>> Let me describe it.:
>>> 
>>> - In a fresh instance of Sling create a sling:folder node named 'one'
>>> - execute this curl call
>>> 
>>> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>> localhost:8080/apps/one/two/three
>>> 
>>> as expected the response is 201 as in [0].
>>> 
>>> So far so good.
>>> But if I change the first step creating a nt:folder rather than a
>> sling:folder I have back a 500 as in [1] with stacktrace:
>>> 
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>>      at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>      ... 40 more
>>> 
>>> see [2] for the complete stacktrace.
>>> Now while I might understand the reason (nt:folder node definition) I
>> think that it would be nice if the SlingPostServlet would handle this case
>> seamlessly.
>>> 
>>> WDYT?
>>> 
>>> Regards
>>> 
>>> Antonio
>>> 
>>> [0]
>>> <html>
>>> <head>
>>>   <title>Content created /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Content created /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">201</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div id="Message">Created</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div
>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [1]  <html>
>>> <head>
>>>   <title>Error while processing /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Error while processing /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">500</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div
>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>> definition for two found in node /apps/one</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div id="ChangeLog"><pre></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>> /apps/one/two/three HTTP/1.1]
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>> during response processing.
>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>> for two found in node /apps/one
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>>>      at
>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>>>      at
>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>>>      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:529)
>>>      at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>>>      at
>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>>>      at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>>>      at
>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>>>      at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>>>      at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>>>      at
>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>>>      at
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>>      at
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>>      at
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>      at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>>      at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>>      at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>>      at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>      at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>      at org.mortbay.jetty.Server.handle(Server.java:326)
>>>      at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>>      at
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>>      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>>      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>      at
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>>      at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>>      at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>      ... 40 more
>> 
>> 


Re: SlingPostServlet

Posted by Carsten Ziegeler <cz...@apache.org>.
2012/11/19 Justin Edelson <ju...@justinedelson.com>:

>
> Is this new behavior? At least in the last release before the recent CRUD
> additions, if there was no node type in the request parameters, the single
> argument addNode() was used, which (based on the JCR spec) uses the child
> node definition from the node type definition. See line 494 of
> https://fisheye6.atlassian.com/browse/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?r=1146769
>
This should still be the same, if there is no node type set, then
addNode(name) is used.

Carsten

> Justin
>
>
>>
>> You can probably easily "fix" this by adding
>> "-Fjcr:primaryType=nt:unstructured" (or any type accepting a start
>> property)to your curl request. In this case the node type of node three is
>> defined and only the type of two would be inherited from one.
>>
>> Regards
>> Felix
>>
>> Am 19.11.2012 um 15:49 schrieb Antonio Sanso:
>>
>> > Hi *,
>> >
>> > lately I have been heavily using the SlingPostServlet and I have noticed
>> a behavior different than expected.
>> > Let me describe it.:
>> >
>> > - In a fresh instance of Sling create a sling:folder node named 'one'
>> > - execute this curl call
>> >
>> > curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>> localhost:8080/apps/one/two/three
>> >
>> > as expected the response is 201 as in [0].
>> >
>> > So far so good.
>> > But if I change the first step creating a nt:folder rather than a
>> sling:folder I have back a 500 as in [1] with stacktrace:
>> >
>> > Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>> >       at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>> >       at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>> >       ... 40 more
>> >
>> > see [2] for the complete stacktrace.
>> > Now while I might understand the reason (nt:folder node definition) I
>> think that it would be nice if the SlingPostServlet would handle this case
>> seamlessly.
>> >
>> > WDYT?
>> >
>> > Regards
>> >
>> > Antonio
>> >
>> > [0]
>> > <html>
>> > <head>
>> >    <title>Content created /apps/one/two/three</title>
>> > </head>
>> >    <body>
>> >    <h1>Content created /apps/one/two/three</h1>
>> >    <table>
>> >        <tbody>
>> >            <tr>
>> >                <td>Status</td>
>> >                <td><div id="Status">201</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Message</td>
>> >                <td><div id="Message">Created</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Location</td>
>> >                <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Parent Location</td>
>> >                <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Path</td>
>> >                <td><div id="Path">/apps/one/two/three</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Referer</td>
>> >                <td><a href="" id="Referer"></a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>ChangeLog</td>
>> >                <td><div
>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>> >            </tr>
>> >        </tbody>
>> >    </table>
>> >    <p><a href="">Go Back</a></p>
>> >    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>> >    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>> >    </body>
>> >
>> > [1]  <html>
>> > <head>
>> >    <title>Error while processing /apps/one/two/three</title>
>> > </head>
>> >    <body>
>> >    <h1>Error while processing /apps/one/two/three</h1>
>> >    <table>
>> >        <tbody>
>> >            <tr>
>> >                <td>Status</td>
>> >                <td><div id="Status">500</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Message</td>
>> >                <td><div
>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>> definition for two found in node /apps/one</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Location</td>
>> >                <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Parent Location</td>
>> >                <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Path</td>
>> >                <td><div id="Path">/apps/one/two/three</div></td>
>> >            </tr>
>> >            <tr>
>> >                <td>Referer</td>
>> >                <td><a href="" id="Referer"></a></td>
>> >            </tr>
>> >            <tr>
>> >                <td>ChangeLog</td>
>> >                <td><div id="ChangeLog"><pre></pre></div></td>
>> >            </tr>
>> >        </tbody>
>> >    </table>
>> >    <p><a href="">Go Back</a></p>
>> >    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>> >    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>> >    </body>
>> >
>> > [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>> /apps/one/two/three HTTP/1.1]
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>> during response processing.
>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>> for two found in node /apps/one
>> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>> >       at
>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>> >       at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>> >       at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>> >       at
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>> >       at
>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>> >       at
>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>> >       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:529)
>> >       at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>> >       at
>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>> >       at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>> >       at
>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>> >       at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>> >       at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>> >       at
>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>> >       at
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>> >       at
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>> >       at
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>> >       at
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>> >       at
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>> >       at
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>> >       at
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>> >       at
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>> >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>> >       at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>> >       at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>> >       at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>> >       at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>> >       at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>> >       at org.mortbay.jetty.Server.handle(Server.java:326)
>> >       at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>> >       at
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>> >       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>> >       at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>> >       at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>> >       at
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>> >       at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>> > Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>> >       at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>> >       at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>> >       ... 40 more
>>
>>



-- 
Carsten Ziegeler
cziegeler@apache.org

Re: SlingPostServlet

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

Am 19.11.2012 um 16:07 schrieb Justin Edelson:

> Hi Felix,
> 
> On Mon, Nov 19, 2012 at 9:59 AM, Felix Meschberger <fm...@adobe.com>wrote:
> 
>> Hi
>> 
>> The problem here is, that Sling has to create two nodes one/two and
>> one/two/three to place the start property in node three. Your request is
>> underspecified in that no node types are defined for nodes two and three.
>> 
>> There are two options, basically: Sling could fail (as WebDAV does)
>> because two and three are missing and intermediate nodes would be created.
>> Or Sling could somehow create intermediate nodes. We decided to go for the
>> second option.
>> 
>> Now, what node types do we apply ? We decided to go for inheriting the
>> node types from the closest existing ancestor, which is one in this case.
>> 
> 
> Is this new behavior? At least in the last release before the recent CRUD
> additions, if there was no node type in the request parameters, the single
> argument addNode() was used, which (based on the JCR spec) uses the child
> node definition from the node type definition. See line 494 of
> https://fisheye6.atlassian.com/browse/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?r=1146769

Hmm, you may be right. I thought we went like inheriting the node type. But I may well be wrong.

In any case, the result is the same here.

Regards
Felix

> 
> Justin
> 
> 
>> 
>> You can probably easily "fix" this by adding
>> "-Fjcr:primaryType=nt:unstructured" (or any type accepting a start
>> property)to your curl request. In this case the node type of node three is
>> defined and only the type of two would be inherited from one.
>> 
>> Regards
>> Felix
>> 
>> Am 19.11.2012 um 15:49 schrieb Antonio Sanso:
>> 
>>> Hi *,
>>> 
>>> lately I have been heavily using the SlingPostServlet and I have noticed
>> a behavior different than expected.
>>> Let me describe it.:
>>> 
>>> - In a fresh instance of Sling create a sling:folder node named 'one'
>>> - execute this curl call
>>> 
>>> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
>> localhost:8080/apps/one/two/three
>>> 
>>> as expected the response is 201 as in [0].
>>> 
>>> So far so good.
>>> But if I change the first step creating a nt:folder rather than a
>> sling:folder I have back a 500 as in [1] with stacktrace:
>>> 
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>>      at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>      ... 40 more
>>> 
>>> see [2] for the complete stacktrace.
>>> Now while I might understand the reason (nt:folder node definition) I
>> think that it would be nice if the SlingPostServlet would handle this case
>> seamlessly.
>>> 
>>> WDYT?
>>> 
>>> Regards
>>> 
>>> Antonio
>>> 
>>> [0]
>>> <html>
>>> <head>
>>>   <title>Content created /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Content created /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">201</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div id="Message">Created</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div
>> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [1]  <html>
>>> <head>
>>>   <title>Error while processing /apps/one/two/three</title>
>>> </head>
>>>   <body>
>>>   <h1>Error while processing /apps/one/two/three</h1>
>>>   <table>
>>>       <tbody>
>>>           <tr>
>>>               <td>Status</td>
>>>               <td><div id="Status">500</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Message</td>
>>>               <td><div
>> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
>> definition for two found in node /apps/one</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Location</td>
>>>               <td><a href="/apps/one/two/three"
>> id="Location">/apps/one/two/three</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Parent Location</td>
>>>               <td><a href="/apps/one/two"
>> id="ParentLocation">/apps/one/two</a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Path</td>
>>>               <td><div id="Path">/apps/one/two/three</div></td>
>>>           </tr>
>>>           <tr>
>>>               <td>Referer</td>
>>>               <td><a href="" id="Referer"></a></td>
>>>           </tr>
>>>           <tr>
>>>               <td>ChangeLog</td>
>>>               <td><div id="ChangeLog"><pre></pre></div></td>
>>>           </tr>
>>>       </tbody>
>>>   </table>
>>>   <p><a href="">Go Back</a></p>
>>>   <p><a href="/apps/one/two/three">Modified Resource</a></p>
>>>   <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>>>   </body>
>>> 
>>> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
>> /apps/one/two/three HTTP/1.1]
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
>> during response processing.
>> javax.jcr.nodetype.ConstraintViolationException: No child node definition
>> for two found in node /apps/one
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
>>>      at
>> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
>>>      at
>> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
>>>      at
>> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
>>>      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:529)
>>>      at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
>>>      at
>> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
>>>      at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
>>>      at
>> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
>>>      at
>> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
>>>      at
>> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
>>>      at
>> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
>>>      at
>> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
>>>      at
>> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
>>>      at
>> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
>>>      at
>> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
>>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
>>>      at
>> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>>>      at
>> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
>>>      at
>> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>>>      at
>> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>>>      at
>> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>>>      at org.mortbay.jetty.Server.handle(Server.java:326)
>>>      at
>> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>>>      at
>> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
>>>      at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
>>>      at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>>>      at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>>>      at
>> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
>>>      at
>> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
>>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
>> child node definition found for {}two
>>>      at
>> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>>>      at
>> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>>>      at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>>>      ... 40 more
>> 
>> 


Re: SlingPostServlet

Posted by Justin Edelson <ju...@justinedelson.com>.
Hi Felix,

On Mon, Nov 19, 2012 at 9:59 AM, Felix Meschberger <fm...@adobe.com>wrote:

> Hi
>
> The problem here is, that Sling has to create two nodes one/two and
> one/two/three to place the start property in node three. Your request is
> underspecified in that no node types are defined for nodes two and three.
>
> There are two options, basically: Sling could fail (as WebDAV does)
> because two and three are missing and intermediate nodes would be created.
> Or Sling could somehow create intermediate nodes. We decided to go for the
> second option.
>
> Now, what node types do we apply ? We decided to go for inheriting the
> node types from the closest existing ancestor, which is one in this case.
>

Is this new behavior? At least in the last release before the recent CRUD
additions, if there was no node type in the request parameters, the single
argument addNode() was used, which (based on the JCR spec) uses the child
node definition from the node type definition. See line 494 of
https://fisheye6.atlassian.com/browse/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?r=1146769

Justin


>
> You can probably easily "fix" this by adding
> "-Fjcr:primaryType=nt:unstructured" (or any type accepting a start
> property)to your curl request. In this case the node type of node three is
> defined and only the type of two would be inherited from one.
>
> Regards
> Felix
>
> Am 19.11.2012 um 15:49 schrieb Antonio Sanso:
>
> > Hi *,
> >
> > lately I have been heavily using the SlingPostServlet and I have noticed
> a behavior different than expected.
> > Let me describe it.:
> >
> > - In a fresh instance of Sling create a sling:folder node named 'one'
> > - execute this curl call
> >
> > curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start
> localhost:8080/apps/one/two/three
> >
> > as expected the response is 201 as in [0].
> >
> > So far so good.
> > But if I change the first step creating a nt:folder rather than a
> sling:folder I have back a 500 as in [1] with stacktrace:
> >
> > Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
> child node definition found for {}two
> >       at
> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
> >       at
> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
> >       ... 40 more
> >
> > see [2] for the complete stacktrace.
> > Now while I might understand the reason (nt:folder node definition) I
> think that it would be nice if the SlingPostServlet would handle this case
> seamlessly.
> >
> > WDYT?
> >
> > Regards
> >
> > Antonio
> >
> > [0]
> > <html>
> > <head>
> >    <title>Content created /apps/one/two/three</title>
> > </head>
> >    <body>
> >    <h1>Content created /apps/one/two/three</h1>
> >    <table>
> >        <tbody>
> >            <tr>
> >                <td>Status</td>
> >                <td><div id="Status">201</div></td>
> >            </tr>
> >            <tr>
> >                <td>Message</td>
> >                <td><div id="Message">Created</div></td>
> >            </tr>
> >            <tr>
> >                <td>Location</td>
> >                <td><a href="/apps/one/two/three"
> id="Location">/apps/one/two/three</a></td>
> >            </tr>
> >            <tr>
> >                <td>Parent Location</td>
> >                <td><a href="/apps/one/two"
> id="ParentLocation">/apps/one/two</a></td>
> >            </tr>
> >            <tr>
> >                <td>Path</td>
> >                <td><div id="Path">/apps/one/two/three</div></td>
> >            </tr>
> >            <tr>
> >                <td>Referer</td>
> >                <td><a href="" id="Referer"></a></td>
> >            </tr>
> >            <tr>
> >                <td>ChangeLog</td>
> >                <td><div
> id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
> >            </tr>
> >        </tbody>
> >    </table>
> >    <p><a href="">Go Back</a></p>
> >    <p><a href="/apps/one/two/three">Modified Resource</a></p>
> >    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
> >    </body>
> >
> > [1]  <html>
> > <head>
> >    <title>Error while processing /apps/one/two/three</title>
> > </head>
> >    <body>
> >    <h1>Error while processing /apps/one/two/three</h1>
> >    <table>
> >        <tbody>
> >            <tr>
> >                <td>Status</td>
> >                <td><div id="Status">500</div></td>
> >            </tr>
> >            <tr>
> >                <td>Message</td>
> >                <td><div
> id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node
> definition for two found in node /apps/one</div></td>
> >            </tr>
> >            <tr>
> >                <td>Location</td>
> >                <td><a href="/apps/one/two/three"
> id="Location">/apps/one/two/three</a></td>
> >            </tr>
> >            <tr>
> >                <td>Parent Location</td>
> >                <td><a href="/apps/one/two"
> id="ParentLocation">/apps/one/two</a></td>
> >            </tr>
> >            <tr>
> >                <td>Path</td>
> >                <td><div id="Path">/apps/one/two/three</div></td>
> >            </tr>
> >            <tr>
> >                <td>Referer</td>
> >                <td><a href="" id="Referer"></a></td>
> >            </tr>
> >            <tr>
> >                <td>ChangeLog</td>
> >                <td><div id="ChangeLog"><pre></pre></div></td>
> >            </tr>
> >        </tbody>
> >    </table>
> >    <p><a href="">Go Back</a></p>
> >    <p><a href="/apps/one/two/three">Modified Resource</a></p>
> >    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
> >    </body>
> >
> > [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST
> /apps/one/two/three HTTP/1.1]
> org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception
> during response processing.
> javax.jcr.nodetype.ConstraintViolationException: No child node definition
> for two found in node /apps/one
> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
> >       at
> org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
> >       at
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
> >       at
> org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
> >       at
> org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
> >       at
> org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
> >       at
> org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
> >       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:529)
> >       at
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
> >       at
> org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
> >       at
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
> >       at
> org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
> >       at
> org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
> >       at
> org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
> >       at
> org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
> >       at
> org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
> >       at
> org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
> >       at
> org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
> >       at
> org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
> >       at
> org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
> >       at
> org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
> >       at
> org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
> >       at
> org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
> >       at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> >       at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> >       at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
> >       at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> >       at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> >       at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> >       at org.mortbay.jetty.Server.handle(Server.java:326)
> >       at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
> >       at
> org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
> >       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
> >       at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> >       at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> >       at
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
> >       at
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> > Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching
> child node definition found for {}two
> >       at
> org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
> >       at
> org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
> >       at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
> >       ... 40 more
>
>

Re: SlingPostServlet

Posted by Felix Meschberger <fm...@adobe.com>.
Hi

The problem here is, that Sling has to create two nodes one/two and one/two/three to place the start property in node three. Your request is underspecified in that no node types are defined for nodes two and three.

There are two options, basically: Sling could fail (as WebDAV does) because two and three are missing and intermediate nodes would be created. Or Sling could somehow create intermediate nodes. We decided to go for the second option.

Now, what node types do we apply ? We decided to go for inheriting the node types from the closest existing ancestor, which is one in this case.

You can probably easily "fix" this by adding "-Fjcr:primaryType=nt:unstructured" (or any type accepting a start property)to your curl request. In this case the node type of node three is defined and only the type of two would be inherited from one.

Regards
Felix

Am 19.11.2012 um 15:49 schrieb Antonio Sanso:

> Hi *,
> 
> lately I have been heavily using the SlingPostServlet and I have noticed a behavior different than expected.
> Let me describe it.:
> 
> - In a fresh instance of Sling create a sling:folder node named 'one'
> - execute this curl call 
> 
> curl -u admin:admin  -F start=@/Users/asanso/test/one/two/three/start localhost:8080/apps/one/two/three
> 
> as expected the response is 201 as in [0].
> 
> So far so good.
> But if I change the first step creating a nt:folder rather than a sling:folder I have back a 500 as in [1] with stacktrace:
> 
> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
> 	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
> 	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
> 	... 40 more
> 
> see [2] for the complete stacktrace.
> Now while I might understand the reason (nt:folder node definition) I think that it would be nice if the SlingPostServlet would handle this case seamlessly.
> 
> WDYT?
> 
> Regards
> 
> Antonio
> 
> [0]
> <html>
> <head>
>    <title>Content created /apps/one/two/three</title>
> </head>
>    <body>
>    <h1>Content created /apps/one/two/three</h1>
>    <table>
>        <tbody>
>            <tr>
>                <td>Status</td>
>                <td><div id="Status">201</div></td>
>            </tr>
>            <tr>
>                <td>Message</td>
>                <td><div id="Message">Created</div></td>
>            </tr>
>            <tr>
>                <td>Location</td>
>                <td><a href="/apps/one/two/three" id="Location">/apps/one/two/three</a></td>
>            </tr>
>            <tr>
>                <td>Parent Location</td>
>                <td><a href="/apps/one/two" id="ParentLocation">/apps/one/two</a></td>
>            </tr>
>            <tr>
>                <td>Path</td>
>                <td><div id="Path">/apps/one/two/three</div></td>
>            </tr>
>            <tr>
>                <td>Referer</td>
>                <td><a href="" id="Referer"></a></td>
>            </tr>
>            <tr>
>                <td>ChangeLog</td>
>                <td><div id="ChangeLog"><pre>created("/apps/one/two");<br/>created("/apps/one/two/three");<br/>created("/apps/one/two/three/start");<br/>created("/apps/one/two/three/start/jcr:content");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:lastModified");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:mimeType");<br/>modified("/apps/one/two/three/start/jcr:content/jcr:data");<br/></pre></div></td>
>            </tr>
>        </tbody>
>    </table>
>    <p><a href="">Go Back</a></p>
>    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>    </body>
> 
> [1]  <html>
> <head>
>    <title>Error while processing /apps/one/two/three</title>
> </head>
>    <body>
>    <h1>Error while processing /apps/one/two/three</h1>
>    <table>
>        <tbody>
>            <tr>
>                <td>Status</td>
>                <td><div id="Status">500</div></td>
>            </tr>
>            <tr>
>                <td>Message</td>
>                <td><div id="Message">javax.jcr.nodetype.ConstraintViolationException: No child node definition for two found in node /apps/one</div></td>
>            </tr>
>            <tr>
>                <td>Location</td>
>                <td><a href="/apps/one/two/three" id="Location">/apps/one/two/three</a></td>
>            </tr>
>            <tr>
>                <td>Parent Location</td>
>                <td><a href="/apps/one/two" id="ParentLocation">/apps/one/two</a></td>
>            </tr>
>            <tr>
>                <td>Path</td>
>                <td><div id="Path">/apps/one/two/three</div></td>
>            </tr>
>            <tr>
>                <td>Referer</td>
>                <td><a href="" id="Referer"></a></td>
>            </tr>
>            <tr>
>                <td>ChangeLog</td>
>                <td><div id="ChangeLog"><pre></pre></div></td>
>            </tr>
>        </tbody>
>    </table>
>    <p><a href="">Go Back</a></p>
>    <p><a href="/apps/one/two/three">Modified Resource</a></p>
>    <p><a href="/apps/one/two">Parent of Modified Resource</a></p>
>    </body>
> 
> [2] 19.11.2012 15:38:52.452 *ERROR* [127.0.0.1 [1353335932442] POST /apps/one/two/three HTTP/1.1] org.apache.sling.servlets.post.impl.operations.ModifyOperation Exception during response processing. javax.jcr.nodetype.ConstraintViolationException: No child node definition for two found in node /apps/one
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1486)
> 	at org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:2082)
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1979)
> 	at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.deepGetOrCreateNode(AbstractCreateOperation.java:416)
> 	at org.apache.sling.servlets.post.impl.operations.AbstractCreateOperation.processCreate(AbstractCreateOperation.java:84)
> 	at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:83)
> 	at org.apache.sling.servlets.post.AbstractSlingPostOperation.run(AbstractSlingPostOperation.java:92)
> 	at org.apache.sling.servlets.post.impl.SlingPostServlet.doPost(SlingPostServlet.java:242)
> 	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:529)
> 	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processComponent(SlingRequestProcessorImpl.java:274)
> 	at org.apache.sling.engine.impl.filter.RequestSlingFilterChain.render(RequestSlingFilterChain.java:49)
> 	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
> 	at org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter.doFilter(RequestProgressTrackerLogFilter.java:59)
> 	at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
> 	at org.apache.sling.engine.impl.SlingRequestProcessorImpl.processRequest(SlingRequestProcessorImpl.java:161)
> 	at org.apache.sling.engine.impl.SlingMainServlet.service(SlingMainServlet.java:183)
> 	at org.apache.felix.http.base.internal.handler.ServletHandler.doHandle(ServletHandler.java:96)
> 	at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:79)
> 	at org.apache.felix.http.base.internal.dispatch.ServletPipeline.handle(ServletPipeline.java:42)
> 	at org.apache.felix.http.base.internal.dispatch.InvocationFilterChain.doFilter(InvocationFilterChain.java:49)
> 	at org.apache.felix.http.base.internal.dispatch.HttpFilterChain.doFilter(HttpFilterChain.java:33)
> 	at org.apache.felix.http.base.internal.dispatch.FilterPipeline.dispatch(FilterPipeline.java:48)
> 	at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:39)
> 	at org.apache.felix.http.base.internal.DispatcherServlet.service(DispatcherServlet.java:67)
> 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
> 	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
> 	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
> 	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
> 	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
> 	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
> 	at org.mortbay.jetty.Server.handle(Server.java:326)
> 	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
> 	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
> 	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
> 	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
> 	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
> 	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
> 	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
> 	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
> 	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
> 	... 40 more


Re: SlingPostServlet

Posted by Antonio Sanso <as...@adobe.com>.
Thanks a lot for the detailed answer Alex.

Antonio

On Nov 19, 2012, at 7:26 PM, Alexander Klimetschek wrote:

> On 19.11.2012, at 15:49, Antonio Sanso <as...@adobe.com> wrote:
> 
>> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
>> 	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
>> 	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
>> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
>> 	... 40 more
>> 
>> see [2] for the complete stacktrace.
>> Now while I might understand the reason (nt:folder node definition) I think that it would be nice if the SlingPostServlet would handle this case seamlessly.
> 
> This issue is that there simply is no "default" child node type for nt:folder. It could be any nt:hiearchyNode, e.g. nt:file or nt:folder, so it's not uniquely defined. That's conceptually, hence why sling cannot choose a default automatically here.
> 
> In JCR you can specify a default node type for a fixed name (e.g. "jcr:content is nt:resource" by default) and IIRC using the wildcard: "* is nt:unstructured" by default (nt:unstructured does that). But the latter is NOT done for nt:folder (for a reason), so there is nothing sling could do about it.
> 
> Except for maybe a better error message, although that would require to look at the exception message (as the exception type ConstraintViolationException is generic).
> 
> Cheers,
> Alex


Re: SlingPostServlet

Posted by Alexander Klimetschek <ak...@adobe.com>.
On 19.11.2012, at 15:49, Antonio Sanso <as...@adobe.com> wrote:

> Caused by: javax.jcr.nodetype.ConstraintViolationException: no matching child node definition found for {}two
> 	at org.apache.jackrabbit.core.nodetype.EffectiveNodeType.getApplicableChildNodeDef(EffectiveNodeType.java:744)
> 	at org.apache.jackrabbit.core.NodeImpl.getApplicableChildNodeDefinition(NodeImpl.java:728)
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1484)
> 	... 40 more
> 
> see [2] for the complete stacktrace.
> Now while I might understand the reason (nt:folder node definition) I think that it would be nice if the SlingPostServlet would handle this case seamlessly.

This issue is that there simply is no "default" child node type for nt:folder. It could be any nt:hiearchyNode, e.g. nt:file or nt:folder, so it's not uniquely defined. That's conceptually, hence why sling cannot choose a default automatically here.

In JCR you can specify a default node type for a fixed name (e.g. "jcr:content is nt:resource" by default) and IIRC using the wildcard: "* is nt:unstructured" by default (nt:unstructured does that). But the latter is NOT done for nt:folder (for a reason), so there is nothing sling could do about it.

Except for maybe a better error message, although that would require to look at the exception message (as the exception type ConstraintViolationException is generic).

Cheers,
Alex