1 Reply Latest reply on Jan 5, 2005 12:35 PM by Scott Stark

    UserTransaction with non default ProviderURL

    Dirk Niemeier Newbie

      Hi,
      I try to use the transactionmanagement from client like the manual says :

      InitialContext ctx = new InitialContext();
       tx = (UserTransaction) ctx.lookup("UserTransaction");
       tx.begin();
       ...

      That works realy fine. But when I am connected to an user defined provider

      java.util.Hashtable env = new java.util.Hashtable();
       env.put( Context.PROVIDER_URL, "myserver:1199");
       InitialContext ctx = new InitialContext(env);
       tx = (UserTransaction) ctx.lookup("UserTransaction");


      it fails (at lookup) with following exception:
      javax.naming.CommunicationException: Failed to connect to server mydefaultserver:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 172.30.1.22:1099 [Root exception is java.net.ConnectException: Connection timed out: connect]]
      
       at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:213)
      
       at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1187)
      ...
      


      Is there any solution for this problem ?

      I think the problem is in org.jboss.tm.usertx.client.ClientUserTransactionObjectFactory:
      static private UserTransaction getUserTransaction()
       {
       if (userTransaction == null) {
       // See if we have a local TM
       try {
       new InitialContext().lookup("java:/TransactionManager");
      
       // We execute in the server.
       userTransaction = ServerVMClientUserTransaction.getSingleton();
       } catch (NamingException ex) {
       // We execute in a stand-alone client.
       userTransaction = ClientUserTransaction.getSingleton();
       }
       }
       return userTransaction;
       }


      because a new InitialContext will be created.

      TIA
      Dirk