Expand my Community achievements bar.

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

Avatar

Level 2
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)
5 Replies

Avatar

Level 2

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.

Avatar

Level 8

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.

Avatar

Level 8

Hi,

Also, are there too many tags present under the path you mentioned?

Would it be possible to delete them manually from backend and see how it goes.

Avatar

Level 2

Yes, scheduler is deleting and creating tags to refresh the list. This code is the back end code running as osgi bundle