为什么我在AEM上路径存在时会收到“javax.jcr.PathNotFoundException”错误?

huangapple go评论69阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2020年8月12日 07:38:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63367770.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定