내 커뮤니티 업적 표시줄을 확대합니다.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Facing the problem while create the node help me out

Avatar

Level 2

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.ht...but 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

"

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee

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 답변 개

Avatar

정확한 답변 작성자:
Employee

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

Avatar

Level 10

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

Avatar

Level 2

            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

Avatar

Level 10

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

Avatar

Level 10

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);