1 Reply Latest reply on Mar 30, 2004 10:37 AM by Scott Stark

    "UT factory lookup failed" when obtaining a UserTransaction

    rwilkinson Newbie

      I'm trying the obtain a UserTransaction via a JNDI lookup from an external (BeanShell) client. I'm using Jboss 3.2.3.

      myUserTransaction = (UserTransaction) context.lookup("UserTransaction");

      but get:

      javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
      at org.jboss.tm.usertx.client.ClientUserTransaction.begin(ClientUserTransaction.java:107)

      I've look at the offending code in JBoss and find this:

      try {
      // Get a reference to the UT session factory.
      UserTransactionSessionFactory factory;
      factory = (UserTransactionSessionFactory)new InitialContext().lookup("UserTransactionSessionFactory");
      // Call factory to get a UT session.
      session = factory.newInstance();
      } catch (Exception ex) {
      throw new RuntimeException("UT factory lookup failed: " + ex);

      From the JBoss documentation it implies that I don't have to configure anything to use UserTransaction because by default it's switch on.

      Any help/advice would be greatly appricated.


        • 1. Re:
          Scott Stark Master

          This code expects that the default ctor of the InitialContext will work. This requires that either the correct jndi.properties file is available to the app classloaders or that the JNDI properties are set as system properties.