You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by Kevin Wiggen <kw...@xythos.com> on 2006/01/11 19:12:10 UTC

Beginners JTA question

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


RE: Beginners JTA question

Posted by Giota Karadimitriou <Gi...@eurodyn.com>.
By making jackrabbit a resource adapter, the transactions are handled by
the application server. At the end of the transaction, the application
server persists the changes to the database (or filesystem). 
 
In this context, where should I close the session (perform
session.logout?).
Is session.logout automatically done by the application server at the
end of the transaction? 

If not, I have a problem because I have no idea where to perform
session.logout since my transactional method could be called by another
transactional method and so on. I have no way of finding out where the
transaction really ends since for example one session bean might call or
extend some other etc.

On the other hand if I never perform session.logout (like I do now) I am
afraid all these sessions might create problems in my application. 

To sum up, the question is:

Does the application server perform session.logout(dispose session)
after the end of a transaction (when using jackrabbit as a resource
adapter)? If not how/where should session.logout be done?

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 = (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 <kw...@xythos.com> 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
> >
> >
> >
>
>
>



RE: Beginners JTA question-problems with clone when using container

Posted by Giota Karadimitriou <Gi...@eurodyn.com>.
Hello Dominique,

yes, this test reflects what I try to do but in my case it fails when
the setProperty is invoked on the cloned node

I use oc4j application server, on windows 2000 environment, java version
"1.4.2_07" and I use SimpleDBPersistenceManager and
org.apache.jackrabbit.core.fs.local.LocalFileSystem.

Here is a more detailed code snippet +exception message

try {
          String originalWorkspace = entry.getWorkspace();
          String originalPath = entry.getAbsolutePath();
//get session for the new workspace
          Session session = getSession(Constants.ARCHIVE_WORKSPACE);
          log.debug("session=" + session);
          Workspace ws = session.getWorkspace();
          log.debug("ws=" + ws.getName());
          String name=JCRUtil.getName(originalPath);
          log.debug("name=" + name);
          ws.clone(originalWorkspace, originalPath,
                  Constants.PATH_SEPARATOR_CHAR + name, true);
          Node rn = session.getRootNode();
          log.debug("rn=" + rn);
          Node archivedNode = rn.getNode(name);  
          log.debug("archivedNode=" + archivedNode);
          archivedNode.setProperty(archivedProperties[0],
                  originalWorkspace);  //HERE it fails
          archivedNode.setProperty(archivedProperties[1],
                  originalPath);
          session.save();
          return archivedNode;
      } catch (Exception e) {
          e.printStackTrace();
      }
     

    [java] > session=org.apache.jackrabbit.jca.JCASessionHandle@2b452b
    [java] > 12:09:40.062 DEBUG JCR..     - ws=attic
    [java] > 12:09:40.062 DEBUG JCR..     - name=99
    [java] > 12:09:40.203 DEBUG JCR..     - rn=org.apache
.jackrabbit.core.NodeImpl@5102ff
    [java] > 12:09:40.203 DEBUG JCR..
-archivedNode=org.apache.jackrabbit.core.NodeImpl@9bc5f9

[java] Caused by: javax.jcr.ItemNotFoundException: failed to build path
of
428b0a98-46c2-4bf4-b954-cd6d85b253c4:
428b0a98-46c2-4bf4-b954-cd6d85b253c4: 428b
0a98-46c2-4bf4-b954-cd6d85b253c4
     [java]     at
org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(Hiera
rchyManagerImpl.java:361)
     [java]     at
org.apache.jackrabbit.core.CachingHierarchyManager.getPath(Ca
chingHierarchyManager.java:220)
     [java]     at
org.apache.jackrabbit.core.lock.LockManagerImpl.getPath(LockM
anagerImpl.java:542)
     [java]     at
org.apache.jackrabbit.core.lock.LockManagerImpl.checkLock(Loc
kManagerImpl.java:455)
     [java]     at
org.apache.jackrabbit.core.NodeImpl.checkLock(NodeImpl.java:3
840)
     [java]     at
org.apache.jackrabbit.core.PropertyImpl.checkSetValue(Propert
yImpl.java:246)
     [java]     at
org.apache.jackrabbit.core.PropertyImpl.setValue(PropertyImpl
.java:768)
     [java]     at
org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java
:1985)
     [java]     at
org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java
:1966)
     [java]     at
com.ed.ecomm.edcore.business.jcr.JCRMutatorManagerBean.archiv
eNode(JCRMutatorManagerBean.java:1455)
     [java]     ... 28 more
     [java] Caused by:
org.apache.jackrabbit.core.state.NoSuchItemStateException
: 428b0a98-46c2-4bf4-b954-cd6d85b253c4
     [java]     at
org.apache.jackrabbit.core.state.SessionItemStateManager.getI
temState(SessionItemStateManager.java:133)
     [java]     at
org.apache.jackrabbit.core.HierarchyManagerImpl.getItemState(
HierarchyManagerImpl.java:119)
     [java]     at
org.apache.jackrabbit.core.HierarchyManagerImpl.getPath(Hiera
rchyManagerImpl.java:356)
     [java]     ... 37 more
     [java]      -----

-----Original Message-----
From: dominique.pfister@gmail.com [mailto:dominique.pfister@gmail.com]
On Behalf Of Dominique Pfister
Sent: Tuesday, February 14, 2006 11:29 AM
To: jackrabbit-dev@incubator.apache.org
Subject: Re: Beginners JTA question-problems with clone when using
container

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 = helper.getSuperuserSession("test");
       Node otherRoot = testSuperuser.getRootNode();
       Node otherNode = otherRoot.addNode("a");
       otherRoot.save();

       // get user transaction object
       UserTransaction utx = new UserTransactionImpl(superuser);

       // start transaction
       utx.begin();

       // clone node from "test" workspace
       superuser.getWorkspace().clone("test",
               otherNode.getPath(), testRoot + "/a", true);
       Node cloned = (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 <Gi...@eurodyn.com> 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 = session.getRootNode();
> log.debug("rn=" + rn);
> Node movedNode = rn.getNode(name);
> log.debug("movedNode=" + 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 = (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 <kw...@xythos.com> 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
> >
> >
> >
>
>
>


Re: Beginners JTA question-problems with clone when using container

Posted by Dominique Pfister <do...@day.com>.
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 = helper.getSuperuserSession("test");
       Node otherRoot = testSuperuser.getRootNode();
       Node otherNode = otherRoot.addNode("a");
       otherRoot.save();

       // get user transaction object
       UserTransaction utx = new UserTransactionImpl(superuser);

       // start transaction
       utx.begin();

       // clone node from "test" workspace
       superuser.getWorkspace().clone("test",
               otherNode.getPath(), testRoot + "/a", true);
       Node cloned = (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 <Gi...@eurodyn.com> 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 = session.getRootNode();
> log.debug("rn=" + rn);
> Node movedNode = rn.getNode(name);
> log.debug("movedNode=" + 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 = (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 <kw...@xythos.com> 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
> >
> >
> >
>
>
>

RE: Beginners JTA question-problems with clone when using container

Posted by Giota Karadimitriou <Gi...@eurodyn.com>.

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 = session.getRootNode();
log.debug("rn=" + rn);
Node movedNode = rn.getNode(name);
log.debug("movedNode=" + 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 = (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 <kw...@xythos.com> 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
>
>
>



RE: Beginners JTA question

Posted by Giota Karadimitriou <Gi...@eurodyn.com>.
Thank you very much Dominique, these guidelines are really important 
as they are the first ones I came across all this time that have showed
me a way to try and embed transaction handling with application server.

I tried to do what you suggested but still have problems with rar
deployment. I just wanted to report to the list that I think I found a
small error in the example ds file in deploy/jboss/4.x. 
The connection definition tag should be (according to JBoss
documentation) the ConnectionFactory interface defined in the ra.xml NOT
the connection interface.

Therefore instead of 
<connection-definition>javax.jcr.Session</connection-definition>

it should be 

<connection-definition>javax.jcr.Repository</connection-definition>

right?

Sth else, should the rar be deployed as part of an ear or standalone?

I try to deploy it standalone for the time being, but I get a "Could not
create connection factory exception". I know this is application server
specific and I have been looking into relevant docs/forums but if
somebody has tried what Dominique suggests and has come across similar
behaviour please shed some light on what could be the problem. Thanks.

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 = (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 <kw...@xythos.com> 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
>
>
>


Re: Beginners JTA question

Posted by Dominique Pfister <do...@day.com>.
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 = (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 <kw...@xythos.com> 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
>
>
>

Re: Beginners JTA question

Posted by Dominique Pfister <do...@day.com>.
Hi Renoir,

apparently WL invokes
JCAManagedConnectionFactory.createManagedConnection and passes null
for both Subject and ConnectionRequestInfo, which is something the jca
contribution does not expect. JCAManagedConnectionFactory.openSession
will try to extract credentials and workspace from the passed "null"
ConnectionRequestInfo and throws.

But, I'm afraid, the jca contrib will have to be revamped in your case
anyway, as BEA WLS 8.1 SP3 comes with connection API from J2EE SDK
1.3, whereas the jca contrib uses features from J2EE SDK 1.4 such as
creating a javax.resource.ResourceException with a base exception.

Regards
Dominique

On 2/9/06, Renoir <re...@sti.com.tw> wrote:
>
> Costin Leau <costin.leau <at> gmail.com> writes:
>
> >
> > You might want to check the JCR support part of the Spring Modules
> > (https://springmodules.dev.java.net) CVS.
> > It includes local transactional support and sample for both local and
> > JTA driven (through JCA) transactions.
> >
> > > 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
> >
> >
> I try to deploy the jackrabbit ica 1.0 to BEA WLS8.1SP3, but there
> is error when I start the WLS,
>
> <Warning> <Connector> <sti-renoir> <cgServer> <main> <<WLS Kernel>> <> <BEA-
> 190032> << Jackrabbit JCR Adapter_comp/env/jcr/repository >
> ResourceAllocationException of java.lang.NullPointerException on
> createManagedConnection.>
> <Warning> <Connector> <sti-renoir> <cgServer> <main> <<WLS Kernel>> <> <BEA-
> 190024> << Jackrabbit JCR Adapter_comp/env/jcr/repository > Error making
> initial connections for pool. Reason: java.lang.NullPointerException>
>
>   I check the JNDI tree there is the entry I specify, but don't know why
> the "NullPointerException" occur?
>
>   The complete weblogic_ra.xml list as follow:
> <!DOCTYPE weblogic-connection-factory-dd PUBLIC '-//BEA Systems, Inc.//DTD
> WebLogic 8.1.0
> Connector//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic810-ra.dtd'>
> <weblogic-connection-factory-dd>
>   <connection-factory-name>contentRepository</connection-factory-name>
>   <jndi-name>comp/env/jcr/repository</jndi-name>
>   <pool-params>
>     <initial-capacity>1</initial-capacity>
>     <max-capacity>10</max-capacity>
>     <capacity-increment>1</capacity-increment>
>     <shrinking-enabled>true</shrinking-enabled>
>     <connection-profiling-enabled>false</connection-profiling-enabled>
>     <shrink-frequency-seconds>900</shrink-frequency-seconds>
>     <inactive-connection-timeout-seconds>0</inactive-connection-timeout-seconds>
>     <highest-num-waiters>2147483647</highest-num-waiters>
>     <highest-num-unavailable>0</highest-num-unavailable>
>     <connection-creation-retry-frequency-seconds>0</connection-creation-retry-
> frequency-seconds>
>     <connection-reserve-timeout-seconds>10</connection-reserve-timeout-seconds>
>     <test-frequency-seconds>0</test-frequency-seconds>
>     <match-connections-supported>true</match-connections-supported>
>   </pool-params>
> </weblogic-connection-factory-dd>
>
>
> Renoir
>
>
>

Re: Beginners JTA question

Posted by Renoir <re...@sti.com.tw>.
Costin Leau <costin.leau <at> gmail.com> writes:

> 
> You might want to check the JCR support part of the Spring Modules
> (https://springmodules.dev.java.net) CVS.
> It includes local transactional support and sample for both local and
> JTA driven (through JCA) transactions.
> 
> > 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
> 
> 
I try to deploy the jackrabbit ica 1.0 to BEA WLS8.1SP3, but there
is error when I start the WLS, 
 
<Warning> <Connector> <sti-renoir> <cgServer> <main> <<WLS Kernel>> <> <BEA-
190032> << Jackrabbit JCR Adapter_comp/env/jcr/repository > 
ResourceAllocationException of java.lang.NullPointerException on 
createManagedConnection.> 
<Warning> <Connector> <sti-renoir> <cgServer> <main> <<WLS Kernel>> <> <BEA-
190024> << Jackrabbit JCR Adapter_comp/env/jcr/repository > Error making 
initial connections for pool. Reason: java.lang.NullPointerException> 
 
  I check the JNDI tree there is the entry I specify, but don't know why
the "NullPointerException" occur?
 
  The complete weblogic_ra.xml list as follow:
<!DOCTYPE weblogic-connection-factory-dd PUBLIC '-//BEA Systems, Inc.//DTD 
WebLogic 8.1.0 
Connector//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic810-ra.dtd'>
<weblogic-connection-factory-dd>
  <connection-factory-name>contentRepository</connection-factory-name>
  <jndi-name>comp/env/jcr/repository</jndi-name>  
  <pool-params>
    <initial-capacity>1</initial-capacity>
    <max-capacity>10</max-capacity>
    <capacity-increment>1</capacity-increment>
    <shrinking-enabled>true</shrinking-enabled>
    <connection-profiling-enabled>false</connection-profiling-enabled>
    <shrink-frequency-seconds>900</shrink-frequency-seconds>
    <inactive-connection-timeout-seconds>0</inactive-connection-timeout-seconds>
    <highest-num-waiters>2147483647</highest-num-waiters>
    <highest-num-unavailable>0</highest-num-unavailable>
    <connection-creation-retry-frequency-seconds>0</connection-creation-retry-
frequency-seconds>
    <connection-reserve-timeout-seconds>10</connection-reserve-timeout-seconds>
    <test-frequency-seconds>0</test-frequency-seconds>
    <match-connections-supported>true</match-connections-supported>
  </pool-params>  
</weblogic-connection-factory-dd>
 

Renoir



Re: Beginners JTA question

Posted by Costin Leau <co...@gmail.com>.
You might want to check the JCR support part of the Spring Modules
(https://springmodules.dev.java.net) CVS.
It includes local transactional support and sample for both local and
JTA driven (through JCA) transactions.

> 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




-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com