0 Replies Latest reply on Jun 10, 2010 8:49 AM by michal_szymanski

    Problem with transaction in Jboss (programatic model)

    michal_szymanski

      I try to use  programatic model  transaction for Axis2 Webservice, for this we deployed Axis2 and our  services on Jboss 5.1 . I created XA datasource and without 'begin'  all  transaction are autocommited and it works ok (we use several datasource in transaction but error happens also when we have only one datasource) . But when I put 
      UserTransaction.userTransaction().begin();   I've got following error:


      14:32:57,250 INFO  [STDOUT]  [ERROR] loader constraint violation: loader (instance of  org/apache/axis2/deployment/DeploymentCl
      assLoader) previously  initiated loading for a different type with name  "javax/transaction/UserTransaction"
      java.lang.reflect.InvocationTargetException

       

      Should I  switch off  local transaction or maybe there is other error?
      Below  part of my program.


      import  java.sql.Connection;
          import java.sql.SQLException;
          import  java.sql.Statement;

       

          import javax.naming.InitialContext;
           import javax.naming.NamingException;
          import  javax.sql.DataSource;
          import  javax.transaction.HeuristicMixedException;
          import  javax.transaction.HeuristicRollbackException;
          import  javax.transaction.NotSupportedException;

          import  javax.transaction.RollbackException;
          import  javax.transaction.SystemException;
          import  org.apache.log4j.Logger;
          import  com.arjuna.ats.jta.UserTransaction;

       

          public CreateServiceResponse  createService(String token, String serviceName, String serviceType,  String consolePassword) {

       

              InitialContext dic;
               try {
                  dic = new InitialContext();
                   DataSource dsUms = (DataSource)  dic.lookup("java:jdbc/UMSDbDS");           
                  Connection  conUms = null;
                  conUms = dsUms.getConnection();
                  
                  try {
                       UserTransaction.userTransaction().begin();        /* EXCEPTION  HAPPENS  HERE !! */
                  } catch (NotSupportedException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
                  } catch (SystemException e) {
                       // TODO Auto-generated catch block
                       e.printStackTrace();
                     
                  Statement  stmtUms = conUms.createStatement();;
                  String sql = "update  dict.cfg_dictionary set description='DUPAUMS_1'";
                   stmtUms.executeUpdate(sql);

       

      Michal Szymanski

      http://blog.szymanskich.net

      http://techblog.freeconet.pl