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

    UserTransaction: Rollback not rolling back

    craigpardey

      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




        • 1. Re: UserTransaction: Rollback not rolling back

          Enable TRACE logging for
          org.jboss.tm
          org.jboss.resource
          in conf/log4j.xml
          then look in log/server.log

          You don't show your db code or say which version
          you are using, so it is hard to help you.

          Regards,
          Adrian

          • 2.
            craigpardey

            I'm using JBoss 3.0.6.

            Enabling the trace showed nothing for the jboss.tm classes except for 'starting' and 'stopping' messages for the service.

            There were a few "cannot be Bound, doesn't have local and local home interfaces" messages when the EJBs are being deployed.

            • 3. Re: UserTransaction: Rollback not rolling back
              craigpardey

              For what it's worth, I also tried container managed and throwing an EJBException and that didn't work either. I also tried sessionContext.setRollbackOnly() to no avail.

              I am thinking it is something to do with my Oracle datasource configuration. Any thoughts on this? It just doesn't seem to want to participate in the transaction.