(Sorry for the many mails on this.) After I added the mix:versionable as described in my previous posting, with saving the session in between, I am not able to retrieve the history of it, as I am getting an error as follows:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: Base version does not exist for /documents/versiontest17.jpg This is what my node looks like after I created it and added the mixin: { "jcr:created": "Mon Dec 19 2016 20:02:43 GMT+0100", "jcr:isCheckedOut": true, "jcr:mixinTypes": [ "mix:referenceable", "mix:versionable" ], "jcr:createdBy": "admin", "jcr:uuid": "6481825f-09f0-4639-b166-7bd450cfa836", "jcr:primaryType": "nt:file", "jcr:content": { "jcr:lastModifiedBy": "admin", ":jcr:data": 3, "jcr:lastModified": "Mon Dec 19 2016 20:02:43 GMT+0100", "jcr:uuid": "dd466d5c-0cf8-41da-a86a-c2e7bc3efadd", "jcr:primaryType": "nt:resource" } } >From my understanding, the baseVersion should be automatically initialized when the node is made versionable?! https://docs.adobe.com/content/docs/en/spec/jcr/2.0/15_Versioning.html "Additionally, under full versioning: The REFERENCE property jcr:baseVersion of N is initialized to the identifier of V0. This constitutes a reference from N to its current base version." mathiasconradt wrote > I just noticed, I can add the mix:versionable when I save the session in > between creating the new node and adding the mixin. > Not sure if this is supposed to work like this and mandatory to save the > session first or not. > > So this works: > > Node fileNode = folderNode.addNode(filename, "nt:file"); > session.save(); > fileNode.addMixin("mix:versionable"); > session.save(); > > - Mathias > > mathiasconradt wrote >> I am getting the same error message with the current trunk as of today. >> Created a new node and added the "mix:versionable" mixable. >> >> fileNode = folderNode.addNode(filename, "nt:file"); >> if (fileNode.canAddMixin("mix:referenceable")) >> fileNode.addMixin("mix:referenceable"); >> if (fileNode.canAddMixin("mix:versionable")) >> fileNode.addMixin("mix:versionable"); >> // if (fileNode.canAddMixin("mix:simpleVersionable")) >> fileNode.addMixin("mix:simpleVersionable"); >> >> Error: >> >> org.springframework.web.util.NestedServletException: Request processing >> failed; nested exception is >> javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: >> /documents/versiontest3.jpg[[nt:file, mix:referenceable, >> mix:versionable]]: Mandatory property jcr:predecessors not found in a new >> node >> >> >> (However, I don't get the message if I add the "mix:simpleVersionable" >> instead, which makes sense though since it does not seem to be >> implemented according to https://issues.apache.org/jira/browse/OAK-4166: >> "As a result, versioning-related methods invoked on such >> [simpleVersionable] nodes doesn't work correctly.) >> >> I looked up the definition: >> >> https://docs.adobe.com/content/docs/en/spec/jcr/2.0/15_Versioning.html >> >> "Under both simple and full versioning, on persist of a new versionable >> node N that neither corresponds nor shares with an existing node: >> >> Additionally, under full versioning: >> >> The multi-value REFERENCE property jcr:predecessors of N is initialized >> to contain a single identifier, that of V0 (the same as >> jcr:baseVersion)." >> >> Now I am wondering, should all this (initialization of the >> jcr:predecessors property) not be handled by the repository automatically >> in both cases, since it knows whether this is a new node etc.? Is it a >> bug? >> >> I found Jira tickets related to versioning, but they are already three >> years old and set to resolved. >> >> https://issues.apache.org/jira/browse/OAK-815 >> https://issues.apache.org/jira/browse/OAK-1118 >> >> Regards, >> Mathias >> >> smg11 wrote >>> Hi While accessing Jackrabbit oak through deployed Jackrabbit oak >>> web-app using rmi, I am getting following error while check in the node >>> to repository. >>> >>> Stack trace: >>> Exception in thread "main" >>> javax.jcr.nodetype.ConstraintViolationException: OakConstraint0021: >>> /testNode_1462713844833[[nt:unstructured, mix:versionable]]: Mandatory >>> property jcr:predecessors not found in a new node >>> at >>> org.apache.jackrabbit.rmi.server.ServerObject.getRepositoryException(ServerObject.java:109) >>> at >>> org.apache.jackrabbit.rmi.server.ServerSession.save(ServerSession.java:265) >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >>> at >>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) >>> at >>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >>> at java.lang.reflect.Method.invoke(Method.java:498) >>> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323) >>> at sun.rmi.transport.Transport$1.run(Transport.java:200) >>> at sun.rmi.transport.Transport$1.run(Transport.java:197) >>> at java.security.AccessController.doPrivileged(Native Method) >>> at sun.rmi.transport.Transport.serviceCall(Transport.java:196) >>> at >>> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) >>> at >>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) >>> at >>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) >>> at java.security.AccessController.doPrivileged(Native Method) >>> at >>> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) >>> at >>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) >>> at >>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) >>> at java.lang.Thread.run(Thread.java:745) >>> at >>> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276) >>> at >>> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253) >>> at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162) >>> at org.apache.jackrabbit.rmi.server.ServerSession_Stub.save(Unknown >>> Source) >>> at >>> org.apache.jackrabbit.rmi.client.ClientSession.save(ClientSession.java:272) >>> at TestJCRVersionable.main(TestJCRVersionable.java:23) >>> >>> >>> >>> Code snippet: >>> >>> public class TestJCRVersionable { >>> >>> public static void main(String[] args) throws Exception { >>> Repository repository = new >>> URLRemoteRepository("http://localhost:8080/oak/rmi"); >>> Session session = repository.login(new >>> SimpleCredentials("admin", >>> "admin".toCharArray())); >>> >>> Node root = session.getRootNode(); >>> long id=System.currentTimeMillis(); >>> >>> //create versionable node >>> Node n = root.addNode("testNode_" + id, "nt:unstructured"); >>> n.addMixin("mix:versionable"); >>> session.save(); >>> >>> VersionManager vMgr = >>> session.getWorkspace().getVersionManager(); >>> vMgr.checkin("/testNode_" + id); >>> >>> session.logout(); >>> >>> } >>> >>> } -- View this message in context: http://jackrabbit.510166.n4.nabble.com/Mandatory-property-jcr-predecessors-not-found-in-a-new-node-tp4664014p4665904.html Sent from the Jackrabbit - Dev mailing list archive at Nabble.com.