Return-Path: Delivered-To: apmail-incubator-jackrabbit-dev-archive@www.apache.org Received: (qmail 59851 invoked from network); 14 Feb 2006 09:29:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Feb 2006 09:29:01 -0000 Received: (qmail 96211 invoked by uid 500); 14 Feb 2006 09:28:56 -0000 Mailing-List: contact jackrabbit-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-dev@incubator.apache.org Received: (qmail 96200 invoked by uid 99); 14 Feb 2006 09:28:56 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 01:28:56 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of dominique.pfister@gmail.com designates 64.233.184.198 as permitted sender) Received: from [64.233.184.198] (HELO wproxy.gmail.com) (64.233.184.198) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Feb 2006 01:28:53 -0800 Received: by wproxy.gmail.com with SMTP id i27so1110847wra for ; Tue, 14 Feb 2006 01:28:33 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=NLiJEDh2FyG7tiC5WLz8jpPFY6TKksesD/loZ20S/pARgTBpBLozPU30VAxnPEGuQ+sCybVK09XUjkaYHW+iSK1+quRfjVSlvfrm4sCniQxiD1ToD/W49/bTbpFk8buIjNWWcSOuQmMbXbzWsbU5tc6TYXskgC/gtLsPs3uwdms= Received: by 10.54.72.17 with SMTP id u17mr968756wra; Tue, 14 Feb 2006 01:28:32 -0800 (PST) Received: by 10.54.145.20 with HTTP; Tue, 14 Feb 2006 01:28:32 -0800 (PST) Message-ID: <66c10f230602140128o388a6ec3oadec814eec9a01e8@mail.gmail.com> Date: Tue, 14 Feb 2006 10:28:32 +0100 From: Dominique Pfister Sender: dominique.pfister@gmail.com To: jackrabbit-dev@incubator.apache.org Subject: Re: Beginners JTA question-problems with clone when using container In-Reply-To: <003901c62e5d$800475d0$b6fdfe0a@gkaradimitr> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <003f01c62710$27ee5a90$b6fdfe0a@gkaradimitr> <003901c62e5d$800475d0$b6fdfe0a@gkaradimitr> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi Giota, Following your description, I wrote a simple test case and added it to my local XATest class contained in the org.apache.jackrabbit.core package: /** * Test cloning a node and setting its properties. */ public void testCloneNode() throws Exception { // add a new node to the "test" workspace Session testSuperuser =3D helper.getSuperuserSession("test"); Node otherRoot =3D testSuperuser.getRootNode(); Node otherNode =3D otherRoot.addNode("a"); otherRoot.save(); // get user transaction object UserTransaction utx =3D new UserTransactionImpl(superuser); // start transaction utx.begin(); // clone node from "test" workspace superuser.getWorkspace().clone("test", otherNode.getPath(), testRoot + "/a", true); Node cloned =3D (Node) superuser.getItem(testRoot + "/a"); // set some properties on cloned node cloned.setProperty("originalPath", otherNode.getPath()); cloned.setProperty("originalWorkspace", otherNode.getSession().getWorkspace().getName()); cloned.save(); } This test case creates a new node in the "test" workspace and then clones it to the "default" workspace. It runs without problems and the new node gets visible to other sessions on the same workspace only after commit, as expected. Of course, it uses the "dummy" UserTransaction object and is therefore possibly not as representative as an appserver environment. Could you tell me, whether this test case reflects what you are doing? It could be helpful, if you would supply information about your environment (OS/Appserver/JVM) too... Regards Dominique On 2/10/06, Giota Karadimitriou wrote: > > > I know I bring up an old thread but I would like to share some problems > I encountered lately, related to jackrabbit and transactions when using > a container. > > After Dominique's excellent suggestion to make jackrabbit a resource > adapter (thanks again Dominique!), things worked ok for me for a while. > > However I recently ran into some new problems. The scenario I wanted to > perform is the following, > > 1. I move a node from one workspace to another using clone > > wsDest.clone(originalWorkspace, originalPath, > name, true); > > 2. And then I want to set 2 of its properties, namely originalPath and > originalWorkspace. > > ... > Node rn =3D session.getRootNode(); > log.debug("rn=3D" + rn); > Node movedNode =3D rn.getNode(name); > log.debug("movedNode=3D" + movedNode); > movedNode.setProperty("originalPath",originalPath); !!!!HERE EXCEPTION > movedNode.setProperty("originalWorkspace",originalWorkspace); > session.save(); > > The problem I encountered was that an 'ItemNotFound exception' happens > in this step when I call setProperty, even though the moved node is > succefully printed in the previous step. > > This happens probably because now that jackrabbit is transactional, the > 'move' only takes place virtually and not physically until the end of > the transaction, thus preventing jackrabbit from really locating the > node when trying to setProperty. > > However, the question is should jackrabbit throw such an exception since > the 'move' changes are not yet persisted? Is there a way to check > persistency and not to try to locate sth that is not yet persisted? > > If I try to set the properties on the original node before moving it, > it's 'clone' itself that fails. > > Finally I tried as a final step to create a new node in the other > workspace and copy all the properties of the old one into the new, then > remove the old > and save both sessions (new and old) but then I get a 'Two phase commit > failed' error. > > regards > Giota > > -----Original Message----- > From: dominique.pfister@gmail.com [mailto:dominique.pfister@gmail.com] > On Behalf Of Dominique Pfister > Sent: Thursday, January 12, 2006 9:43 AM > To: jackrabbit-dev@incubator.apache.org > Subject: Re: Beginners JTA question > > Hi Kevin, > > The UserTransactionImpl in Jackrabbit is used solely for testing > purposes, where you usually don't have an application server within > reach, sorry, if this is confusing. > > In order to make Jackrabbit work as an XA resource, you have to make > it available as a resource adapter (RA) in your application server. > There is a contribution named jca in the contrib directory that > packages jackrabbit into a deployable RAR (resource adapter archive). > > For BEA, you'll probably want to add a weblogic-ra.xml to the RAR's > META-INF folder that specifies the JNDI name where your RA will be > made available to applications. Finally, your web application will > need a resource-ref entry that has to be linked to the RA's JNDI name. > If you then reference this resource in your code: > > Repository rep =3D (Repository) new > InitialContext().lookup("java:comp/env/jackrabbit"); > > it will automatically be enlisted as an XAResource in BEA's > UserTransaction. > > Cheers > Dominique > > On 1/11/06, Kevin Wiggen wrote: > > Sorry if this question is a newbie to JTA question, but I have been > > looking at the jackrabbit code and I can't figure the following out. > > > > > > > > I want to use Jackrabbit in my BEA container and use JTA to coordinate > > the transaction with Jackrabbit and my other JTA transactional > > resources. The other resources already are plugged into the BEA world > > and code uses the BEA UserTransaction to coordinate the interaction > > between these resources. > > > > > > > > The short question is how do I wire up Jackrabbit to work in this > world? > > > > > > > > From what I see (and I can be completely looking in the wrong spot), > > Jackrabbit uses XASessionImpl to appear as a XAResource, and I see in > > XATest how the Jackrabbit UserTransactionImpl is used to get a > > Jackrabbit specific UserTransaction, but I already have my own > > UserTransaction (well BEA's). > > > > > > > > Am I missing something obvious? I just don't see how I can get > > Jackrabbit to play in my UserTransaction world.... > > > > > > > > Thanks for the help, > > > > Kevin > > > > > > > > >