英文:
Why do I get "javax.jcr.PathNotFoundException" when the path exists on AEM?
问题
I am trying to copy node tree of a template to a node named "root" like the following:
Workspace workspace = session.getWorkspace();
workspace.copy(templatePath + "/initial/jcr:content/root", contentNode.getPath() + "/root");
Node rootNode = contentNode.getNode("root");
templatePath is the string to template. I am trying to copy "/initial/jcr:content/root" under the template path and paste it to child node named "root" under the node contentNode.
I ran the code above and got javax.jcr.PathNotFoundException on the last line. When I went to CrxDe on AEM, the node tree has been copied and pasted, and the path actually exists although I got the error message. I tried to add
session.save();
After I copied. But the same error persisted although the nodes exists and have been copied.
What is causing it?
英文:
I am trying to copy node tree of a template to a node named "root" like the following:
Workspace workspace = session.getWorkspace();
workspace.copy(templatePath + "/initial/jcr:content/root", contentNode.getPath() + "/root");
Node rootNode = contentNode.getNode("root");
templatePath is the string to template. I am trying to copy "/initial/jcr:content/root" under the template path and paste it to child node named "root" under the node contentNode.
I ran the code above and got javax.jcr.PathNotFoundException on the last line. When I went to CrxDe on AEM, the node tree has been copied and pasted, and the path actually exists although I got the error message. I tried to add
session.save();
After I copied. But the same error persisted although the nodes exists and have been copied.
What is causing it?
答案1
得分: 1
尝试在再次使用contentNode
之前添加session.refresh()
,而不是session.save()
。
英文:
Instead of session.save()
, try adding a session.refresh()
before you use contentNode
again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论