Atomikos Forum

NonXA Rollback doesn't work

Just downloaded AtomikosTransactionsEssentials-3.5.4 and followed most of the code in NonXaAccount.java. Everything worked except the rollback. As you can see in my code after a successful insert I set the “success” to “false” to force a rollback. It went through the rollback code but didn’t do the rollback. It inserted rows to the database.
Using apache-tomcat-6.0.16, mysql-5.1.34-win32.
Thanks in advance!!

...
import javax.transaction.UserTransaction;
import com.atomikos.icatch.jta.UserTransactionImp; 
import com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean;
   
boolean success=false;
UserTransaction utx = null;
                
try{             
  UserTransactionImp ut = new UserTransactionImp();
  utx = ut;
  utx.begin();
  ds = new AtomikosNonXADataSourceBean();                ds.setUniqueResourceName("jdbc/TestDB");                ds.setDriverClassName("com.mysql.jdbc.Driver");           ds.setUrl("jdbc:mysql://localhost:3306/javatest");
  ds.setUser("xxx");
  ds.setPassword("yyy");
  ds.setPoolSize(1);
        
 
  Connection conn = ds.getConnection();                
  conn.setAutoCommit(false);
  Statement stmt = conn.createStatement();
  String q = "insert into testdata values (24,'22224',24)";
                
  stmt.executeUpdate(q);            
  stmt.close();
  conn.close();
  //success=true;
  success=false;    
}catch(Exception e) {
  e.printStackTrace();
  success=false;
 }finally {
    try {
      out.println("success "+success);
      //UserTransaction utx = new UserTransactionImp();
      if (success) {                      
        utx.commit();
      } else {
        out.println("will rollback "); // it prints this phrase
        //utx.setRollbackOnly();                         utx.rollback(); // doesn't work and no exception
        }
  }catch (Exception e) {
      e.printStackTrace();
      success = false;
    }
}
Jane Lau Send private email
Thursday, June 04, 2009
 
 
What is in the tm.out file (in DEBUG mode)?

Guy
Guy Pardon Send private email
Friday, June 05, 2009
 
 
Sorry for the late reply. Encountered problems when tried to post the log a couple times and still haven't heard from the fogbugz support. Since I don't know what causes the problem so I copy only the text from the log first.

Starting read of logfile C:\eclipse\..\work\tmlog29.log
Done read of logfile
USING com.atomikos.icatch.console_file_name = jane.out
USING com.atomikos.icatch.console_file_count = 5
USING com.atomikos.icatch.automatic_resource_registration = true
USING com.atomikos.icatch.client_demarcation = false
USING com.atomikos.icatch.threaded_2pc = true
USING com.atomikos.icatch.serial_jta_transactions = true
USING com.atomikos.icatch.log_base_dir = ../work
USING com.atomikos.icatch.console_log_level = DEBUG
USING com.atomikos.icatch.max_actives = 50
USING com.atomikos.icatch.checkpoint_interval = 500
USING com.atomikos.icatch.enable_logging = true
USING com.atomikos.icatch.output_dir = ../work
USING com.atomikos.icatch.log_base_name = tmlog
USING com.atomikos.icatch.console_file_limit = 5000000
USING com.atomikos.icatch.max_timeout = 900000
USING com.atomikos.icatch.tm_unique_name = jane
USING java.naming.factory.initial = com.sun.jndi.rmi.registry.RegistryContextFactory
USING java.naming.provider.url = rmi://localhost:1099
USING com.atomikos.icatch.service = com.atomikos.icatch.standalone.UserTransactionServiceFactory
USING com.atomikos.icatch.force_shutdown_on_vm_exit = false
USING com.atomikos.icatch.default_jta_timeout = 10000
getCompositeTransaction() returning NULL!
Coordinator jane0000100011 entering state: ACTIVE
Coordinator jane0000100011 entered state: ACTIVE
TaskManager: initializing...
THREADS: using JDK thread pooling...
THREADS: using executor class com.atomikos.icatch.imp.thread.Java15ExecutorFactory$Executor
(1.5) executing task: com.atomikos.timing.PooledAlarmTimer@b655a
ThreadFactory: creating new thread: Atomikos:0
Creating composite transaction: jane0000100011
createCompositeTransaction ( 10000 ): created new ROOT transaction with id jane0000100011
AtomikosNonXADataSourceBean 'jdbc/TestDB': getConnection ( null )...
AtomikosNonXADataSourceBean 'jdbc/TestDB': init...
AtomikosNonXADataSourceBean 'jdbc/TestDB': initializing with [ uniqueResourceName=jdbc/TestDB, maxPoolSize=1, minPoolSize=1, borrowConnectionTimeout=30, maxIdleTime=60, reapTimeout=0, maintenanceInterval=60, testQuery=null, driverClassName=com.mysql.jdbc.Driver, user=jlau, url=jdbc:mysql://localhost:3306/javatest loginTimeout=0]
atomikos connection pool 'jdbc/TestDB': initializing...
AtomikosNonXAPooledConnection: registering listener atomikos connection pool 'jdbc/TestDB'
(1.5) executing task: com.atomikos.timing.PooledAlarmTimer@39452f
Jane Lau Send private email
Monday, June 08, 2009
 
 
It worked so I'll copy the rest...

ThreadFactory: creating new thread: Atomikos:1
AtomikosNonXADataSourceBean 'jdbc/TestDB': init done.
AtomikosNonXADataSourceBean 'jdbc/TestDB': getConnection ( null )...
AtomikosNonXADataSourceBean 'jdbc/TestDB': init...
atomikos connection pool 'jdbc/TestDB': pool reached max size: 1
atomikos connection pool 'jdbc/TestDB': current size: 1/1
AtomikosNonXAPooledConnection: updating last time acquired
AtomikosNonXAPooledConnection: no test query, skipping test
AtomikosNonXAPooledConnection: creating connection proxy...
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: calling toString on vendor connection...
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: toString returning com.mysql.jdbc.JDBC4Connection@16db492
AtomikosNonXAPooledConnection: returning proxy com.mysql.jdbc.JDBC4Connection@16db492
atomikos connection pool 'jdbc/TestDB': got connection from pool, new size: 1/1
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: calling toString on vendor connection...
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: toString returning com.mysql.jdbc.JDBC4Connection@16db492
AtomikosNonXADataSourceBean 'jdbc/TestDB': returning com.mysql.jdbc.JDBC4Connection@16db492atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: calling toString on vendor connection...
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: toString returning com.mysql.jdbc.JDBC4Connection@16db492
AtomikosNonXADataSourceBean 'jdbc/TestDB': returning com.mysql.jdbc.JDBC4Connection@16db492
getCompositeTransaction()  returning instance with id jane0000100011
Coordinator jane0000100011 entering state: ACTIVE
Coordinator jane0000100011 entered state: ACTIVE
addParticipant ( com.atomikos.jdbc.nonxa.AtomikosNonXAParticipant@1fcd402 ) for transaction jane0000100011
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: calling createStatement on vendor connection...
Jane Lau Send private email
Monday, June 08, 2009
 
 
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: createStatement returning com.mysql.jdbc.StatementImpl@1c2ec05
getCompositeTransaction()  returning instance with id jane0000100011
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: close...
ThreadLocalConnection: not reusable yet
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: close done.
getCompositeTransaction()  returning instance with id jane0000100011
getCompositeTransaction()  returning instance with id jane0000100011
Coordinator jane0000100011 entering state: ABORTING
Jane Lau Send private email
Monday, June 08, 2009
 
 
Coordinator jane0000100011 entering state: ABORTING
(1.5) executing task: com.atomikos.icatch.imp.Propagator$PropagatorThread@18c69a9
ThreadFactory: creating new thread: Atomikos:2
Forcing close of pending statement: com.mysql.jdbc.StatementImpl@1c2ec05
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: transaction aborting - pessimistically closing all pending statements to avoid autoCommit after timeout
atomikos non-xa connection proxy for com.mysql.jdbc.JDBC4Connection@16db492: rolling back on connection...
ThreadLocalConnection: detected reusability
AtomikosNonXAPooledConnection: notifying listener: atomikos connection pool 'jdbc/TestDB'
atomikos connection pool 'jdbc/TestDB': connection AtomikosNonXAPooledConnection became available, notifying potentially waiting threads
Coordinator jane0000100011 entering state: TERMINATED
Coordinator jane0000100011 : stopping timer...
Coordinator jane0000100011 : disposing statehandler TERMINATED...
Coordinator jane0000100011 : disposed.
Coordinator jane0000100011 entered state: TERMINATED
Jane Lau Send private email
Monday, June 08, 2009
 
 
rollback() done of transaction jane0000100011

This's the end of the log. Thanks!
Jane Lau Send private email
Monday, June 08, 2009
 
 
Looks fine in the logs - and rollback is called on the JDBC connection, so...

Please try with the newer 3.5.5 release - if that doesn't work I recommend buying dev support to look into the details.
Guy Pardon Send private email
Monday, June 15, 2009
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics