HI,

Sorry if this is not the right place to post but I have an issue with a simple 
POC using Oak 1.1.0 and MongoDB as a node store.
I would appreciate any help / hints on resolving this issue.

Thanks

I am getting the following exception:
java.lang.RuntimeException: 
org.apache.jackrabbit.oak.api.CommitFailedException: OakMerge0001: 
OakMerge0001: Failed to merge changes to the underlying store (retries 5, 4848 
ms)
       at 
org.apache.jackrabbit.oak.spi.lifecycle.OakInitializer.initialize(OakInitializer.java:64)
       at org.apache.jackrabbit.oak.Oak.createContentRepository(Oak.java:551)
       at org.apache.jackrabbit.oak.jcr.Jcr.createRepository(Jcr.java:196)
       at com.rsd.glass.oak.Poc.main(Poc.java:44)
Caused by: org.apache.jackrabbit.oak.api.CommitFailedException: OakMerge0001: 
OakMerge0001: Failed to merge changes to the underlying store (retries 5, 4848 
ms)
       at 
org.apache.jackrabbit.oak.spi.state.AbstractNodeStoreBranch.merge(AbstractNodeStoreBranch.java:341)
       at 
org.apache.jackrabbit.oak.plugins.document.DocumentNodeStoreBranch.merge(DocumentNodeStoreBranch.java:161)
       at 
org.apache.jackrabbit.oak.plugins.document.DocumentRootBuilder.merge(DocumentRootBuilder.java:159)
       at 
org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore.merge(DocumentNodeStore.java:1290)
       at 
org.apache.jackrabbit.oak.spi.lifecycle.OakInitializer.initialize(OakInitializer.java:62)

Here is my code:

public class Poc {

       public static void main(String args[]) {

             Session session = null;
             try {
                    MongoConnection connection = new 
MongoConnection("127.0.0.1", 27017, "oak");
                    DB db = connection.getDB();

                    DocumentMK.Builder builder = new DocumentMK.Builder();
                    builder.setMongoDB(db);

                    NodeStore nodeStore = new DocumentNodeStore(builder);
                    Repository repository = new 
Jcr(nodeStore).createRepository();
                    session = repository.login(new SimpleCredentials("admin", 
"admin".toCharArray()));

                    Poc poc = new Poc();

                    NodeTypeManager ntm = 
session.getWorkspace().getNodeTypeManager();
                    CndImporter.registerNodeTypes(new 
FileReader("src/main/resources/myMetadata.cnd"), session, true);

                    poc.buildContent(session, poc, ntm);

                    session.save();

                    // Retrieve content
                    Node rootNode = session.getRootNode();
                    Node node = rootNode.getNode("Policies/HR/Contracts");
                    System.out.println(node.getPath());

                    System.exit(0);
             } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    System.exit(-1);
             } finally {
                    if (session != null) {
                           session.logout();
                    }
             }

       }

       private void buildContent(Session session, Poc poc, NodeTypeManager ntm) 
throws Exception {

             if (session.itemExists("/Policies")) {
                    session.removeItem("/Policies");
             }

             // Create Policies tree
             Node rootNode = session.getRootNode();
             Node policiesNode = rootNode.addNode("Policies", "my:policy");
             Node hrNode = policiesNode.addNode("HR", "my:policy");
             hrNode.setProperty("my:metadata", "hr");
             Node contractsNode = hrNode.addNode("Contracts", "my:policy");
             contractsNode.setProperty("my:metadata", "contract");

       }

}

Reply via email to