3 Replies Latest reply on Dec 11, 2003 5:00 PM by craigpardey

    UserTransaction: Rollback not rolling back

    craigpardey Newbie

      Hi,

      I am having some difficulties getting a UserTransaction to roll back. The UserTransaction is created in a stateless, BMT session bean. The database is Oracle 8.1.7.

      The problem is that data inserted/updated during the transaction remains in the database after the rollback. I have tried many different means of transaction management and none of them seem to make any difference.

      Here is a brief snippet of what the code is doing:

      UserTransaction userTransaction = null;
      try
      {
      InitialContext context = new InitialContext();
      userTransaction = (UserTransaction)context.lookup("UserTransaction");
      userTransaction.begin();
      doSomeUpdate();
      if(1==1)
      {
      throw new Exception("Just checking the rollback.");
      }
      userTransaction.commit();
      return SUCCESS;
      }
      catch(Throwable t)
      {
      try
      {
      userTransaction.rollback();
      }
      catch(Throwable x)
      {
      log.error("Unable to roll back transaction", x);
      }
      }


      Given the number of code permutations I have tried, I believe that it is something to do with the way the datasource is configured, or with Oracle itself.

      Here is the datasource configuration.





      <depends optional-attribute-name="ManagedConnectionFactoryName">
      <!--embedded mbean-->


      CDSDataSource


      <config-property name="ConnectionURL" type="java.lang.String">
      jdbc:oracle:thin:@myserver:1521:mydb
      </config-property>
      <config-property name="DriverClass" type="java.lang.String">
      oracle.jdbc.driver.OracleDriver
      </config-property>

      <config-property name="UserName" type="java.lang.String">username</config-property>
      <config-property name="Password" type="java.lang.String">password</config-property>



      <depends optional-attribute-name="OldRarDeployment">
      jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper




      <depends optional-attribute-name="ManagedConnectionPool">
      <!--embedded mbean-->

      5
      15
      5000
      15
      ByContainer



      <depends optional-attribute-name="CachedConnectionManager">
      jboss.jca:service=CachedConnectionManager


      <depends optional-attribute-name="JaasSecurityManagerService">
      jboss.security:service=JaasSecurityManager



      java:/TransactionManager


      <!--make the rar deploy! hack till better deployment-->
      jboss.jca:service=RARDeployer