0 Replies Latest reply on Nov 18, 2005 4:39 PM by rogeduardo

    newbie with jta and jboss

    rogeduardo

      Hello everyone!
      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 ( "Entrei no rollback" );
       user.rollback();
       sex.printStackTrace();
       }
       }
       }
      


      But this code execute as if it did not have the UserTransaction. What I have that to make so this work like atomic transation?

      Thank you very much.