2


I'm using Atomikos essential transactions as my TM in my J2SE application.
I have the following code:

if (userTransaction.getStatus()== Status.STATUS_ACTIVE){
userTransaction.commit();
}

and then I see in the logs the following exception:

java.lang.IllegalStateException: TM_UNIQUE_NAME0003000006 is no longer active but in state TERMINATED at com.atomikos.icatch.imp.CoordinatorImp.addParticipant(CoordinatorImp.java:615) at com.atomikos.icatch.imp.TransactionStateHandler.addParticipant(TransactionStateHandler.java:133) at com.atomikos.icatch.imp.TransactionStateHandler.committed(TransactionStateHandler.java:347) at com.atomikos.icatch.imp.TransactionStateHandler.commit(TransactionStateHandler.java:298) at com.atomikos.icatch.imp.CompositeTransactionImp.doCommit(CompositeTransactionImp.java:319) at com.atomikos.icatch.imp.CompositeTerminatorImp.commit(CompositeTerminatorImp.java:79) at com.atomikos.icatch.jta.TransactionImp.commit(TransactionImp.java:236) at com.atomikos.icatch.jta.TransactionManagerImp.commit(TransactionManagerImp.java:496) at com.atomikos.icatch.jta.UserTransactionImp.commit(UserTransactionImp.java:129) at com.mycompany.module.view.myOtherClass.transformMpr(myOtherClass.java:57) at java.util.Observable.notifyObservers(Unknown Source) at com.mycompany.module.model.myClass.notifyObservers(myClass.java:291) at com.mycompany.module.model.myClass.MultiStateEscalation.run(myClass.java:91) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

Where line 57 in the myOtherClass is the line where I call commit() in the above code. userTransaction is an instance of UserTransaction.
What I can't understand is what does TERMINATED means? I couldn't find these classes in the Atomikos distribution (which is weird since their open source and I additionaly ran a text search for the string over all the sources) and terminated is not one of the statuses defined in javax.transaction.Status.
Has someone incountered this? How can I check if the userTransaction I'm holding is valid for commit?

Thanks,
Ittai

Ittai
  • 5,625
  • 14
  • 60
  • 97

1 Answers1

2

TERMINATED means committed or rolled back. In your case, most likely a timeout / rollback.

Try increasing the timeout if you can.

In general, checking the transaction state does not guarantee that the next line of code can commit. Committing is an application request that can fail due to timeouts and resource issues; otherwise you wouldn't need two-phase-commit :-)

Best

Guy Pardon
  • 484
  • 2
  • 8
  • Thanks. Two question if I may: 1)Assuming it was a timeout (and it did go away once I increased the timeout based on your suggestions in the Atomikos forum) was the TX Active Xms before when the `IF` took place? 2) Why does Atomikos output a state which does not corelate to the JTA Status table? It could be much more helpfull and self explanatory in my opinion. Thanks again for your input. – Ittai Dec 21 '10 at 07:09