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

    Newbie with JTA and JBoss

    rogeduardo

      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.

        • 1. Re: Newbie with JTA and JBoss

          What is SchemaAdmin? Just a stupid POJO? Then it is of course not JTA aware. Please read at least the basics about what JTA is. It doesn't do any magic. If it is an EJB then you must get it via JNDI and not create an instance yourself.

          • 2. Re: Newbie with JTA and JBoss
            rogeduardo

             

            "oglueck" wrote:
            What is SchemaAdmin?

            Its not the problem. My problem here is: i am trying to control operations in distributed environment. This method "addSchemaReference" access via JNI and after a RPC server wrote in C. I wanna control this transactions with JTA, but I dont know how this could be done. I have to implement any Interface, like XAResource, in the server side(C)? Or I dont have worry about this?





            • 3. Re: Newbie with JTA and JBoss

              You have to register you resource with the resource manager. Normally this is done by creating a resource adapter (RAR). Suggested reading: JTA, Java connector architector, resource adapters.

              • 4. Re: Newbie with JTA and JBoss
                rogeduardo

                 

                "oglueck" wrote:
                You have to register you resource with the resource manager. Normally this is done by creating a resource adapter (RAR). Suggested reading: JTA, Java connector architector, resource adapters.

                Thank you. This you be very helpful.