AccessDeniedException on publisher instance on node write
We're having a strange problem on some of our instances.
In some of our template JSPs, we a writing in the repo under /etc/designs/
<% Session session = (resource.getResourceResolver().adaptTo(Session.class)); //... try{ Node n= session.getNode(resourceDesign.getPath()+"/jcr:content/"+template+"/anchors-parsys-layout"); } catch(PathNotFoundException e){ Node n= session.getNode(resourceDesign.getPath()+"/jcr:content/"+template+"").addNode("anchors-parsys-layout","nt:unstructured"); n.setProperty("components", new String[]{"/apps/corpo/components/content/image", "/apps/corpo/components/content/reference", "/apps/corpo/components/content/textimage", "/apps/corpo/components/content/title", "/apps/corpo/components/content/image-banner/image-banner-render", "/apps/corpo/components/content/text/text", "/apps/corpo/components/content/table"}); n.setProperty("sling:resourceType","foundation/components/parsys"); session.save(); } %>Unfortunately, this code throwing AccessDeniedException on some of our publish instances. Moreover, if I log in as admin on those publish instances, it automatically fixes the problem (!)
it's a rather long stacktrace, included as attachment.
Does that rings a bell? Is this the right way to get the session? If so, does the session have admin rights by default?
Thanks for any help.
JS.