[jboss-user] [JCA/JBoss] - Re: Opening connection from a marked rollback tx

adrian@jboss.org do-not-reply at jboss.com
Fri Nov 23 10:19:07 EST 2007


"oglueck" wrote : That makes sense. I don't know if I can reproduce the problem in a reasonably small test case. I can try, but I currently lack the time.

Try


  | // BMT bean
  | public void recreateRandomRollbackOnly() throws Exception
  | {
  |    UserTransaction ut = ..
  |    ut.setTransactionTimeout(5); // 5 second timeout
  |    ut.begin();
  |    try
  |    {
  |         try
  |         {
  |             Thread.sleep(10000); // 10 second sleep
  |         }
  |         catch (InterruptedException ignored)
  |         {
  |         }
  | 
  |         // Transaction has timed out here
  | 
  |         DataSource ds = ...;
  |         ds.getConnection().close(); // Oops can't enlist in dead transaction
  |    }
  |    finally
  |    {
  |        ut.rollback();
  |    }
  | }
  | 

http://java.sun.com/javaee/5/docs/api/javax/transaction/Transaction.html#enlistResource(javax.transaction.xa.XAResource)
anonymous wrote : 
  |     RollbackException - Thrown to indicate that the transaction has been marked for rollback only. 
  |     IllegalStateException - Thrown if the transaction in the target object is in the prepared state or the transaction is inactive.
  | 

If you need to do out-of-bound communication (i.e. read the database
even if the transaction has failed) then you need to use a different transaction,
either RequiresNew or no-tx-connection-manager.

There's nothing you can do in the dead transaction.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4107375#4107375

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4107375



More information about the jboss-user mailing list