You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Ricardo Matinata <ri...@gmail.com> on 2004/10/14 21:14:07 UTC

UserTransaction not working in DefaultContext

Hi,
  As of tomcat-5.0.29, it is not possible to have a
java:/comp/UserTransaction resource working if declared from a
DefaultContext. (ie) :
.......
<GlobalNamingResources>
                <Resource name="UTransaction" auth="Container"
                type="javax.transaction.UserTransaction"/>
                <ResourceParams name="UTransaction">
                        <parameter>
                        <name>factory</name>
                        <value>org.objectweb.jotm.UserTransactionFactory</value>
                        </parameter>
                        <parameter>
                        <name>jotm.timeout</name>
                        <value>60</value>
                        </parameter>
                </ResourceParams>
</GlobalNamingResources>
.......
<Host>
      <DefaultContext>
               <ResourceLink name="UserTransaction" global="UTransaction"
                type="javax.transaction.UserTransaction"/>
       </DefaultContext>
</Host>
.....

  As far as i have investigated the problem, DefaultContext resources
are not avaliable as NamingResources when NamingContextListener
creates the NamingContext for the Context
(NamingContextListener.createNamingContext()). So at the moment 
NamingContext is created, the java:/comp/UserTransation resource is
added with an empty TransactionRef object. Later, in the life cicle,
when DefaultContext resources are added to the context, in this case a
ResourceLink pointing to the UserTransaction  global resource, we get
a NameAlreadyBoundException, so the previously registered
TransactionRef object remains without config parameters.
  The UserTransaction works fine if included in each application's own
context.xml file.
  So, as i haven't found any notes regarding this anywhere (manual,
list and Bugzilla), it is (probably) an issue to be raised (or is it
anticipated behaviour ?).

Thanks.
---
Ricardo

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: UserTransaction not working in DefaultContext

Posted by Ricardo Matinata <ri...@gmail.com>.
Hi,
  I've confirmed my diagnostic about UserTransactions in a
<DefaultContext> , and I've made a patch for it. So now there are a
few questions that I'd gladly request your option on:

- Considering that  tomcat-5.0.x is in maintenance mode, and
DefaultContext stuff has been rewritten in 5.5.x., should I raise this
issue as a bug, and propose my patch ?

- If yes, there are, at least, two possible solutions for this issue.
Which one should be taken ?

     A) one solution that does not interfere if an UserTransaction has
been successfully registered by a <Context> element (more power to the
web-application) even if there is a UserTransaction element in a
<DefaultContext>. This is the solution I've made a patch for.

     B) if a UserTransaction is present in a <DefaultContext>, it will
be the available one. This behavior is the current behavior for the
StandardDefaultContext implementation regarding all resources inside a
<DefaultContext> (yes, the implementation unregisters previous
resources from <Context> initializations from a web-application, and
override them with equally named resources if available inside a
<DefaultContext> for a <Host>).

Regards,
---
Ricardo

---------- Forwarded message ----------
From: Ricardo Matinata <ri...@gmail.com>
Date: Thu, 14 Oct 2004 16:14:07 -0300
Subject: UserTransaction not working in DefaultContext
To: tomcat-dev@jakarta.apache.org


Hi,
  As of tomcat-5.0.29, it is not possible to have a
java:/comp/UserTransaction resource working if declared from a
DefaultContext. (ie) :
.......
<GlobalNamingResources>
                <Resource name="UTransaction" auth="Container"
                type="javax.transaction.UserTransaction"/>
                <ResourceParams name="UTransaction">
                        <parameter>
                        <name>factory</name>
                        <value>org.objectweb.jotm.UserTransactionFactory</value>
                        </parameter>
                        <parameter>
                        <name>jotm.timeout</name>
                        <value>60</value>
                        </parameter>
                </ResourceParams>
</GlobalNamingResources>
.......
<Host>
      <DefaultContext>
               <ResourceLink name="UserTransaction" global="UTransaction"
                type="javax.transaction.UserTransaction"/>
       </DefaultContext>
</Host>
.....

  As far as i have investigated the problem, DefaultContext resources
are not avaliable as NamingResources when NamingContextListener
creates the NamingContext for the Context
(NamingContextListener.createNamingContext()). So at the moment
NamingContext is created, the java:/comp/UserTransation resource is
added with an empty TransactionRef object. Later, in the life cicle,
when DefaultContext resources are added to the context, in this case a
ResourceLink pointing to the UserTransaction  global resource, we get
a NameAlreadyBoundException, so the previously registered
TransactionRef object remains without config parameters.
  The UserTransaction works fine if included in each application's own
context.xml file.
  So, as i haven't found any notes regarding this anywhere (manual,
list and Bugzilla), it is (probably) an issue to be raised (or is it
anticipated behaviour ?).

Thanks.
---
Ricardo

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org