I have the following code in a server side testcase (cactus):
this.userTransaction = (UserTransaction) getInitialContext().lookup("java:comp/UserTransaction");
System.out.println("Returned user transaction has status " + this.userTransaction.getStatus());
Most of the time this goes fine and I can see status 6 (STATUS_NO_TRANSACTION). Other times however, the status is 1 (STATUS_MARKED_ROLLBACK) as if I am reusing a UserTransaction from a previous test case that was marked for rollback. I am quite sure that the previous test case has rolled back the transaction (does that in tearDown).
The problem is that I get an exception when I try to start the transaction.