jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: ItemStateException
Date Mon, 27 Feb 2006 09:39:45 GMT
On 2/27/06, Carlos Villegas <cav@uniscope.jp> 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
>

Mime
View raw message