Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 3120 invoked from network); 11 Dec 2010 14:53:48 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Dec 2010 14:53:48 -0000 Received: (qmail 24285 invoked by uid 500); 11 Dec 2010 14:53:47 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 24014 invoked by uid 500); 11 Dec 2010 14:53:47 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 24006 invoked by uid 99); 11 Dec 2010 14:53:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Dec 2010 14:53:46 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of norman.maurer@googlemail.com designates 209.85.214.172 as permitted sender) Received: from [209.85.214.172] (HELO mail-iw0-f172.google.com) (209.85.214.172) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 Dec 2010 14:53:41 +0000 Received: by iwn40 with SMTP id 40so7251924iwn.17 for ; Sat, 11 Dec 2010 06:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=sWQruNVm33f1VRxkjBFF0GhdE4nbyfvOUDcG6voROz0=; b=j0fGeydjpMIdQkTBaoTKhumQBCnTovHJvPUE8RlYoARpVKUrFqGWK0L9lEDgVo+dM3 t3NwbBHY9MjNKducLIfUcW9g9l/sre9Qg+wurwdmFCef+9XLeiwLUksY7A6UvE2OJO/x iU5o06kyANb1/FQSyxQFzyM/1jakGBGHo4uhs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=bjxZyopC7jEEtfW1jLdhaT3XiZB84zIXxEoZ0/2cismaBrfr9r76w0rB4hFXwH9gkl hFcNgSI59a9KFXrNbHFP6lMIQUyuzZcuPSq094yHBvDTeshgLBoiIw/EW7+3QcKfic51 3a0ZmZLYU2ez74Dpj1yeHDUpFbzy7c3yu5pZs= MIME-Version: 1.0 Received: by 10.231.13.133 with SMTP id c5mr514338iba.39.1292079201104; Sat, 11 Dec 2010 06:53:21 -0800 (PST) Sender: norman.maurer@googlemail.com Received: by 10.231.37.69 with HTTP; Sat, 11 Dec 2010 06:53:21 -0800 (PST) In-Reply-To: References: <75C9DCDE-6160-4F78-AC44-411CAD562B8D@maya-systems.com> <1E19575A-B03C-4E98-969B-8D347BA34AF5@maya-systems.com> Date: Sat, 11 Dec 2010 15:53:21 +0100 X-Google-Sender-Auth: LNz0MbPayn8e40oBIiC-pvCV1a4 Message-ID: Subject: Re: Item cannot be saved because it has been modified externally: node / From: Norman Maurer To: users@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi there, unfortunaly I don't know the issue number out of my head. I just know I had the same problems with concurrent write operations and talked to Jukka about it. He told me its fixed in 2.2-SNAPSHOT and I tried it (he even gave me an issue number but I can't remember) to see if the problems are still there. It was fixed for me.. Bye, Norman 2010/12/11 Stefan Guggisberg : > On Sat, Dec 11, 2010 at 11:52 AM, Norman Maurer wrote= : >> >> Hi there, >> >> this is fixed in the upcomming jackrabbit 2.2.0 (which should be > > which jira issue are you refering to? > > cheers > stefan > >> released within the next days). In the meantime you can grab a >> snapshot here: >> >> https://repository.apache.org/content/groups/snapshots/org/apache/jackra= bbit/ >> >> Version name is 2.2-SNAPSHOT. >> >> Bye, >> Norman >> >> >> >> >> 2010/12/11 Fran=E7ois Cassistat : >> > I've managed to make some basic case that throws the error every time. >> > >> > import org.apache.jackrabbit.core.TransientRepository; >> > >> > import javax.jcr.*; >> > >> > public class JCRConcurrency >> > { >> > =A0 =A0public static void main(String[] args) throws RepositoryExcepti= on >> > =A0 =A0{ >> > =A0 =A0 =A0 =A0Repository repo; >> > =A0 =A0 =A0 =A0if (args.length >=3D 2) >> > =A0 =A0 =A0 =A0 =A0 =A0repo =3D new TransientRepository(args[0], args[= 1]); >> > =A0 =A0 =A0 =A0else >> > =A0 =A0 =A0 =A0 =A0 =A0repo =3D new TransientRepository(); >> > =A0 =A0 =A0 =A0SimpleCredentials simpleCredentials =3D new SimpleCrede= ntials("username", "password".toCharArray()); >> > =A0 =A0 =A0 =A0Session sessionInit =3D repo.login(simpleCredentials); >> > >> > =A0 =A0 =A0 =A0// initialization >> > =A0 =A0 =A0 =A0Node root =3D sessionInit.getRootNode(); >> > =A0 =A0 =A0 =A0Node test; >> > =A0 =A0 =A0 =A0if (root.hasNode("test")) >> > =A0 =A0 =A0 =A0 =A0 =A0test =3D root.getNode("test"); >> > =A0 =A0 =A0 =A0else >> > =A0 =A0 =A0 =A0 =A0 =A0test =3D root.addNode("test"); >> > =A0 =A0 =A0 =A0if (!test.hasProperty("property")) >> > =A0 =A0 =A0 =A0 =A0 =A0test.setProperty("property", 0); >> > =A0 =A0 =A0 =A0sessionInit.save(); >> > =A0 =A0 =A0 =A0String testIdentifier =3D test.getIdentifier(); >> > >> > =A0 =A0 =A0 =A0// session 1 >> > =A0 =A0 =A0 =A0Session session1 =3D repo.login(simpleCredentials); >> > =A0 =A0 =A0 =A0Node test1 =3D session1.getNodeByIdentifier(testIdentif= ier); >> > =A0 =A0 =A0 =A0System.out.println(test1.getProperty("property").getLon= g()); >> > =A0 =A0 =A0 =A0test1.setProperty("property", 1); >> > >> > =A0 =A0 =A0 =A0// session 2 is doing some other things at the same tim= e >> > =A0 =A0 =A0 =A0Session session2 =3D repo.login(simpleCredentials); >> > =A0 =A0 =A0 =A0Node test2 =3D session2.getNodeByIdentifier(testIdentif= ier); >> > =A0 =A0 =A0 =A0test2.setProperty("property", 2); >> > >> > =A0 =A0 =A0 =A0// session 2 saves first >> > =A0 =A0 =A0 =A0session2.save(); >> > =A0 =A0 =A0 =A0session2.logout(); >> > >> > =A0 =A0 =A0 =A0// session 1 saves >> > =A0 =A0 =A0 =A0session1.save(); >> > =A0 =A0 =A0 =A0session1.logout(); >> > >> > =A0 =A0 =A0 =A0sessionInit.logout(); >> > >> > =A0 =A0 =A0 =A0System.exit(0); >> > =A0 =A0} >> > } >> > >> > >> > >> > >> > Le 2010-12-10 =E0 6:12 PM, Fran=E7ois Cassistat a =E9crit : >> > >> >> Hi list ! >> >> >> >> I've got some concurrency problem while saving. My application use di= stinct Sessions object and when two processes are trying to modify the same= property of the same node at the same time. I've get the exception below : >> >> javax.jcr.InvalidItemStateException: Item cannot be saved because it = has been modified externally: node / >> >> =A0 =A0 =A0 =A0at org.apache.jackrabbit.core.ItemImpl.getTransientSta= tes(ItemImpl.java:249) >> >> =A0 =A0 =A0 =A0at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.j= ava:981) >> >> =A0 =A0 =A0 =A0at org.apache.jackrabbit.core.SessionImpl.save(Session= Impl.java:920) >> >> =A0 =A0 =A0 =A0at com.myproject.MyProject.save(MyProject.java:1525) >> >> =A0 =A0 =A0 =A0... >> >> >> >> >> >> I have tried saving this way : >> >> synchronized (this) >> >> { >> >> =A0 =A0session.refresh(true); >> >> =A0 =A0session.save(); >> >> } >> >> >> >> >> >> Is there any way around or only locks and transactions can prevent th= at ? >> >> >> >> >> >> Thanks ! >> >> >> >> >> >> Fran=E7ois >> >> >> > >> > >