4 Replies Latest reply on Nov 19, 2005 2:01 PM by Rogerio Oliveira

    Newbie with JTA and JBoss

    Rogerio Oliveira Newbie

      Hello to all,

      I'm newbie with JTA and JBoss. Forgive me if my question is very stupid. This is my code:

      public class Application {
      
       public static String URL = "java:comp/UserTransaction";
      
       public Application() throws IllegalStateException, SecurityException, SystemException {
      
       UserTransaction user = null;
       SchemaAdmin schema = new SchemaAdmin();
      
       try
       {
       Context ic = new InitialContext();
       user = (UserTransaction) ic.lookup(URL);
      
       user.begin();
      
      
       schema.addSchemaReference( "172.25.0.3", "rogerio.schema" );
       schema.addSchemaReference( "172.25.0.20", "rogerio.schema
      " );
       schema.addSchemaReference( "172.25.0.19", "rogerio.schema" );
       schema.addSchemaReference( "172.25.0.22", "
      rogerio.schema" );
      
       user.commit();
      
       }catch ( NamingException nex ){
       nex.printStackTrace();
       }
       catch ( Exception sex ){
       System.out.println ( "rollback" );
       user.rollback
      ();
       sex.printStackTrace();
       }
       }
      }




      This code execute as if it did not have the UserTransaction. It not work like a atomic transaction, when it execute rollback dont return to a stable state. What I have to do so this work like atomic transation?

      Thank you.