Could this error happen if two threads are working simultaneously on the
same session?
I have a InputStream property in one node and spawn a thread to pipe an
OutputStream from some process. It seems, in a slow machine, since the
process already closed the OutputStream, it goes on saving other
properties in the same node. However, the piping thread may still be
executing the final node.save(). The interesting thing is that I
reversed the calls and now I don't see the error anymore. In other
words, I execute the pipe at the end, and then return control to the
interactive GUI, so no more JCR operations happens for a while.
Carlos
Stefan Guggisberg wrote:
On 2/27/06, Carlos Villegas <[EMAIL PROTECTED]> wrote:
What does the following exception mean:
javax.jcr.InvalidItemStateException:
d35eb7b6-ca1a-4c18-98fc-0aa0ee9b8987: the item cannot be saved because
it has been modified externally.
There's only one application using the repository. What could be happening?
this exception indicates that you have 2 separate sessions that try to modify
the *same* item.
the following code fragment illustrates this:
Node a1 = session1.getRootNode().getNode("a");
Node a2 = session2.getRootNode().getNode("a");
// session 1 modifies node a
a1.addNode("b");
// session 2 modifies node a
a2.addNode("c");
// session 1 saves its changes
a1.save();
// session 2 tries to save its changes but gets
// an InvalidItemStateException because its
// changes have become stale
a2.save(); // throws
you can avoid such situations if you lock the node before
you start modifiying it.
cheers
stefan
Carlos