4 Replies Latest reply on Mar 14, 2005 2:10 PM by perisb

    UserTransaction and non-default JNDI context.

    zacjacobson

      I have a webapp that running in Tomcat that accesses my EJBs that live in a separately-running jBoss. Tomcat has a lot of other webapps that use the default (tomcat's) JNDI service, so I have to use

      Context ctx = new InitialContext(jBossJndiProperties);

      to access my EJBs. This works fine except for the UserTransaction. When I call begin() on my Transaction, I get
      javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed: javax.naming.NameNotFoundException: Name UserTransactionSessionFactory is not bound in this Context

      I searched around on the web, and it would seem that the org.jboss.tm.usertx.client.ClientUserTransaction builds its own JNDI Context using the default InitialContext constructor.

      Is there a workaround that would somehow let pass in a Context, or provide some other mechanism to allow the ClientUserTransaction to use my non-default JNDI Context?

      I'm using jBoss 2.4.10, is the functionality I need provided in more recent versions?

        • 1. Re: UserTransaction and non-default JNDI context.
          zacjacobson

          I downloaded the source for JBoss 3.2.5, and the UserTransaction works the same way, so updating JBoss won't help me in this case.

          If someone knows a workaround for this situation, I would definitely appreciate hearing it.

          • 2. Re: UserTransaction and non-default JNDI context.
            starksm64

            Your going to have to hack the ClientUserTransaction to expose a thread local to which a Properties/Hashtable can be placed for use by the InitialContext. The j2ee appclient naming context factory should be providing a binding for the user transaction as well that would give more control over this, but currently its not.

            • 3. Re: UserTransaction and non-default JNDI context.
              zacjacobson

              Thanks for the suggestion, I will look into that.

              I also thought about making a UserTransaction available from Tomcat's JNDI (eg Tyrex) - but I don't really undersand if or how that would work - could commit/rollback on a UserTransaction that lives in Tomcat affect my beans in JBoss?

              • 4. Re: UserTransaction and non-default JNDI context.

                 

                "scott.stark@jboss.org" wrote:
                Your going to have to hack the ClientUserTransaction to expose a thread local to which a Properties/Hashtable can be placed for use by the InitialContext. The j2ee appclient naming context factory should be providing a binding for the user transaction as well that would give more control over this, but currently its not.


                I've got this problem, too, at version 3.2.5. Since this doesn't seem to be an overly exotic requirement, is there, or will there be a fix in the future? This may be a problem with the design of JNDI--I'm not sure.

                Short of a fix, can anyone post a working version of the hack described? Thanks.

                -Peris