javax.jcr.nodetype.ConstraintViolationException: Item is protected. | Community
Skip to main content
Level 2
May 17, 2017

javax.jcr.nodetype.ConstraintViolationException: Item is protected.

  • May 17, 2017
  • 1 reply
  • 3675 views
I am trying to delete existing nodes and then add new nodes under etc/tags/plant. The code is below. I see error when deleting a node. What ACL's needs to be there for service account to delete a node. String mainPath = "/etc/tags/plant";                 Tag mainTag = tagManager.resolve(mainPath);                 if (mainTag != null) {                     logger.debug("Main Tag already exists ");                     Resource res = resourceResolver.getResource(mainPath);                     Node plantNode =res.adaptTo(Node.class);                     Iterator i = plantNode.getNodes();                     while(i.hasNext()){                         ((Node)i.next()).remove(); // This is generating error                     } javax.jcr.nodetype.ConstraintViolationException: Item is protected. at org.apache.jackrabbit.oak.jcr.session.ItemImpl$ItemWriteOperation.checkPreconditions(ItemImpl.java:98) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:615) at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.performVoid(SessionDelegate.java:271) at org.apache.jackrabbit.oak.jcr.session.NodeImpl.remove(NodeImpl.java:218) at com.gm.gpsc.sdlaem.core.schedulers.CountryTagUpdateScheduledTask.run(CountryTagUpdateScheduledTask.java:94) at org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:118) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

cquser1
Level 7
May 17, 2017
Level 2
May 17, 2017

I have created systemuser as per that documentation and given service user admin privileges, still the bundle is not able to delete a node in /etc/tags/plant folder. Keep getting 

javax.jcr.nodetype.ConstraintViolationException: Item is protected.
cquser1
Level 7
May 17, 2017

Hi,

Looking at the stack trace, I see

at com.gm.gpsc.sdlaem.core.schedulers.CountryTagUpdateScheduledTask.run(CountryTagUpdateScheduledTask.java:94)

Is it something like this code is part of a scheduler running in the system.