CQ5 Unable to update a stale item: item.save() javax.jcr.InvalidItemStateException: Unable to update a stale item: item.save() | Community
Skip to main content
Community Advisor
October 16, 2015
Solved

CQ5 Unable to update a stale item: item.save() javax.jcr.InvalidItemStateException: Unable to update a stale item: item.save()

  • October 16, 2015
  • 2 replies
  • 2193 views

I am using workflow to copy lots of pdfs from one location to other dam locations based on the data and set of requirements. I am using the following code Asset damAsset = manager.createAsset(path, is, mimeType,true); where path is the destination dire and 'is' is inputstream pdf file, there is no metadata on I am applying the metadata to destination file using following statement Node node = damAsset.adaptTo(Node.class); Node mdNode = node.getNode("jcr:content/metadata"); mdNode.setProperty("pttitle", forms.getFileDisplayTitle()); Once all the files are finished I am terminating the workflow uing workflowSession.terminateWorkflow(workItem.getWorkflow());

Workflow works fine for most of the time but last file didn't set with the metadata due to following exception. This exception happens randomly once after running repeatedly for 3-4 times.

javax.jcr.InvalidItemStateException: Unable to update a stale item: item.save()at org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation.java:262)at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216)at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:329)at org.apache.jackrabbit.core.session.SessionSaveOperation.perform(SessionSaveOperation.java:65)at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)at java.lang.Thread.run(Unknown Source)Caused by: org.apache.jackrabbit.core.state.StaleItemStateException: 1f6fc642-1a20-4cac-abe5-70f903aefde4 has been modified externally at org.apache.jackrabbit.core.state.SharedItemStateManager$Update.begin(SharedItemStateManager.java:679)at org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation.java:258
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

There is an explanation for this in this Apache mailing list:

https://www.mail-archive.com/dev@archiva.apache.org/msg01883.html

It looks like this occurs if another process trying to access/scan the node. 

2 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

There is an explanation for this in this Apache mailing list:

https://www.mail-archive.com/dev@archiva.apache.org/msg01883.html

It looks like this occurs if another process trying to access/scan the node. 

MshajiCommunity AdvisorAuthor
Community Advisor
October 16, 2015

Hi Sam,

Thanks for the reply, I checked the link you sent to me, this is happening for the last file in the workflow upload process.

Node is not being used anywhere

It is an exception which causes loss of the metadata I applied to the pdf node.

I removed terminateWorkfow statement as workflow completes successfully. Initially I thought of terminating workflow but I was wrong

I cannot even catch this exception as it is thrown internally inside CQ5.

Please let me know if you have any updates.