SNS problem
bwallis42 Apr 2, 2013 9:02 AMThis is a question about a problem I've been staring at and playing with for many long hours now. It should be simple and just work but I am obviously missing something. I have had the code in question running before (probably with a beta of 3.0) but it might have changed a little since then. I'm currently running the code in jboss EAP6.1 alpha and with a recent modeshape snapshot of 3.2. I also tried it with boss 7.1.1 and 3.1.3 modeshape with the same results.
I just cannot see what I am doing wrong here. I don't have a simple test case (tried to create one but it works ok!)
Any suggestions if you can see something I am doing wrong here would be greatly appreciated.
I have the following snipit of code
{code} Node newNode = new JaxbNodeTransformer().includeProperties(true).includeSubnodes(true).includeMixins(true).toJcrNode(parentNode, nodeDef);
log.debug("Created Node "+newNode.getIdentifier()+" path="+newNode.getPath()
+" in parent node "+parentNode.getIdentifier()+" path="+parentNode.getPath());
log.debug(" Parent Node type="+parentNode.getPrimaryNodeType());
log.debug(" This Node type="+newNode.getPrimaryNodeType());
log.debug(" This node allows SNS Sibs = "+newNode.getDefinition().allowsSameNameSiblings());
log.debug(" This node name = "+newNode.getDefinition().getName());
nodeIds.add(newNode.getIdentifier());
}
session.save();
{code}
The newNode creation is buried inside some xml processing but just calls addNode on the node passed in as parentNode (which is of type inf:patient). The part of the schema used is
{code}[inf:patient] > mix:versionable, nt:hierarchyNode
+ * (inf:patientId) COPY
+ * (inf:section) SNS COPY
- inf:masterId (STRING) mandatory COPY
- inf:masterNs (STRING) mandatory COPY
/**
* A section node is a named container of either episodes or documents.
*/
[inf:section] > nt:hierarchyNode orderable
- inf:name (STRING) mandatory COPY
+ * (nt:hierarchyNode) SNS VERSION
{code}
and I get the following output which looks like what I expect, particularly bit about the SNS sibs being true.
{code}23:35:54,997 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.utils.JaxbNodeTransformer] (http-localhost/127.0.0.1:8080-1) Add node inf:section with type inf:section
23:35:55,002 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation] (http-localhost/127.0.0.1:8080-1) Created Node e2758128-8560-415e-85b6-daceb07ff381 path=/inf:patient/inf:section[2] in parent node ab2cf616-579e-4bb1-9570-874ba9e76264 path=/inf:patient
23:35:55,002 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation] (http-localhost/127.0.0.1:8080-1) Parent Node type=inf:patient
23:35:55,003 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation] (http-localhost/127.0.0.1:8080-1) This Node type=inf:section
23:35:55,003 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation] (http-localhost/127.0.0.1:8080-1) This node allows SNS Sibs = true
23:35:55,003 DEBUG [au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation] (http-localhost/127.0.0.1:8080-1) This node name = *
{code}
but when the session.save() is called I get an error where it complains about not allowing SNS siblings
{code}Caused by: java.lang.RuntimeException: Could not perform operation over the repository
at au.com.infomedix.jcrloadtest.jcrserver.repo.JcrService.executeCommand(JcrService.java:92) [classes:]
at au.com.infomedix.jcrloadtest.jcrserver.restapi.NodeCrudMethods.create(NodeCrudMethods.java:59) [classes:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_17]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_17]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_17]
at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_17]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167) [resteasy-jaxrs-2.3.5.Final.jar:]
at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.5.Final.jar:]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.5.Final.jar:]
at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.5.Final.jar:]
at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542) [resteasy-jaxrs-2.3.5.Final.jar:]
... 19 more
Caused by: javax.jcr.ItemExistsException: A node definition that allows same name siblings could not be found for the node "{http://infomedix.com.au/inf}section" in workspace "default"
at org.modeshape.jcr.JcrSession$JcrPreSave.processAfterLocking(JcrSession.java:1914)
at org.modeshape.jcr.cache.document.WritableSessionCache.runPreSaveAfterLocking(WritableSessionCache.java:479)
at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:540)
at org.modeshape.jcr.JcrSession.save(JcrSession.java:986)
at au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation.performOperation(CreateNodeOperation.java:63) [classes:]
at au.com.infomedix.jcrloadtest.jcrserver.operations.CreateNodeOperation.performOperation(CreateNodeOperation.java:1) [classes:]
at au.com.infomedix.jcrloadtest.jcrserver.repo.AbstractJcrOperation.execute(AbstractJcrOperation.java:43) [classes:]
at au.com.infomedix.jcrloadtest.jcrserver.repo.JcrService.executeCommand(JcrService.java:84) [classes:]
... 29 more
{code}
I am stumped by this.