Facing the problem while create the node help me out | Community
Skip to main content
October 16, 2015
Solved

Facing the problem while create the node help me out

  • October 16, 2015
  • 5 replies
  • 1384 views

I just trying to create the node in the cq and migrating the aem6 to mongodb and supported jars listed below

Oak-jcr-0.9.jar, Oak-core-0.8.jar, oak-mongomk-0.8, oak-mongomk-0.9 by importing the com.mongodb.*, org.apache.jackrabbit.oak.*, and other corresponding packages

and i tried to create the node using the others site help like "http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2013/12/starting_with_apacheoak.htmlbut the main issues is that after writting the code when i compile the code i am facing the problem like this

"

Exception in thread "main" java.lang.ExceptionInInitializerError

    at org.apache.jackrabbit.oak.kernel.KernelNodeState.readProperty(KernelNodeState.java:638)
    at org.apache.jackrabbit.oak.kernel.KernelNodeState.init(KernelNodeState.java:180)
    at org.apache.jackrabbit.oak.kernel.KernelNodeState.hasChildNode(KernelNodeState.java:262)
    at org.apache.jackrabbit.oak.plugins.memory.MutableNodeState.hasChildNode(MutableNodeState.java:268)
    at org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder.hasChildNode(MemoryNodeBuilder.java:262)
    at org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent.initialize(InitialContent.java:52)
    at org.apache.jackrabbit.oak.spi.lifecycle.CompositeInitializer.initialize(CompositeInitializer.java:47)
    at org.apache.jackrabbit.oak.spi.lifecycle.OakInitializer.initialize(OakInitializer.java:43)
    at org.apache.jackrabbit.oak.Oak.createContentRepository(Oak.java:247)
    at org.apache.jackrabbit.oak.jcr.Jcr.createRepository(Jcr.java:153)
    at CreateCollectiobn.main(CreateCollectiobn.java:100)
Caused by: java.lang.IllegalArgumentException: unknown type: 10
    at javax.jcr.PropertyType.nameFromValue(PropertyType.java:92)
    at org.apache.jackrabbit.oak.kernel.TypeCodes.<clinit>(TypeCodes.java:40)
    ... 11 more

"

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JustinEd3

That blog post is about bootstrapping a new Oak instance. If you are using AEM, you already have an instance of Oak running. You should just use the JCR API to create nodes.

Regards,

Justin

5 replies

JustinEd3Adobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

That blog post is about bootstrapping a new Oak instance. If you are using AEM, you already have an instance of Oak running. You should just use the JCR API to create nodes.

Regards,

Justin

Sham_HC
October 16, 2015

it is compile time issue & need to verify your code. Post your example. 

October 16, 2015

            Repository repo = new Jcr(kernel).createRepository();           
            ContentRepository repository = new Oak().createContentRepository();*/
            Root root = new Oak().createRoot();
            Session session  =  repo.login(new SimpleCredentials("admin", "admin".toCharArray()));
            Node rootNode = (Node) session.getRootNode();
            ((javax.jcr.Node) rootNode).addNode("oakrocks", "nt:unstructured");
            session.save();

Iam using the above for node creation in mongodbmk and its giving me any compilation error and while executing the program its giving the error

Thanks,

Pavan

Lokesh_Shivalingaiah
October 16, 2015

Hi Pavan,

  for AEM, you dont have to create a new repository as it will already be existing. you can just login, use the jcr api and create the nodes

Lokesh_Shivalingaiah
October 16, 2015

import com.day.cq.commons.jcr.JcrUtil;

@reference

Session session;

 

session = repo.loginAdministrative(null);
Node root = session.getRootNode();

boolean nodeCheck = root.hasNode(nodePath);

Node path = null;
if(!nodeCheck){
      JcrUtil.createPath(nodePath, NT_UNSTRUCTURED, NT_UNSTRUCTURED, session, true);
}
path = root.getNode(nodePath);