Issue 1:
Deep Banduri opened SPR-4184 and commented

We are seeing an issue that happens with Jboss 4.2.x where a transaction is not rolling back when the time out period has elapsed.

Following is the scenario and how I can consistently reproduce the error.

We have a transactional method on a bean with 2 db update operations - 1 insert and 1 delete as follows:

public void foo() {

dbInsertOperation();

dbDeleteOperation();

}

I used a very small transaction time of 2 seconds, and then waited on a break point on the dbDeleteOperation line to ensure that the time out period elapses, and then executed the delete operation. What we found is that in 4.2.1, while waiting at the breakpoint, after the time out is detected by JBoss, the database receives a Rollback command from the app server which rolls back the inserted records - and the method still has not completed yet. When I then execute the delete operation, it is executed by SQL Server as a standalone transaction, since the original one associated with the method is already rolled back. When the method now returns, Spring code tries to commit the transaction, gets an IllegalStateException exception, and then tries to rollback and gets another exception. So what we have is the inserted records were rolled back but the deleted records were commited resulting in an inconsistent database.

However this same exact sequence of events in 4.0.3 works exactly as one would logically expect - even after I sit on the breakpoint for a while for the time out period to elapse, then execute the delete statement, it is still part of the transaction associated with the method call. AFter the method call, Spring code tries to commit, gets an exception (I think a RollbackException), and then issues a rollback which is sent to the database and the entire transaction (insert and delete) is rolled back.

So it seems that what was working logically in 4.0.3 seems to be broken in 4.2.x, everything else being equal. Question is why is JBoss issuing a rollback in the middle of the method? I opened a support ticket with JBoss Support - their response is that this is something Spring should be fixing. See below for their response:

I believe this is a problem with Spring. It should be checking the thread-to-transaction association of the thread doing the delete. In the case of the timeout, it will find that there is an inactive transaction associated with the thread (the transaction has rolled back, but it has not been removed from the active thread). It should not be trying to make forward progress with the thread at that point, particularly if the thread is about to try to do something within the scope of that transaction.

The reason this worked in the 4.0.3 release was that the transaction was not rolled back, so the delete operation was done in the scope of the transaction, even though by that point the state of the transaction would have been marked as ROLLBACK_ONLY, i.e., the delete was wasted effort, so it's arguable that Spring should have checked the state anyway and optimised that operation away, since it wasn't going to complete.

JBossTS now terminates transactions as soon as their timeout goes off. The old JBossTM did not: it simply marked them as ROLLBACK_ONLY, which will force them to rollback only when the container eventually tries to commit the transaction.

Thanks,

Deep

Affects: 2.0.6

Issue Links:

#8786 Transaction Manager issue "NO Active JTA Transaction". Sprying trying to synchronise a transaction marked for rollback.

Issue 2:
Kavipriya Gnanasambandam opened SPR-4107 and commented

I am using Spring 2.0.2 with JBoss 4.2.1 which uses Arjuna Transaction Manager. When i am trying to rollback a transaction i am getting the error message as IllegalStateException"No Active JTA Transaction" The integration between Spring and JBOSS does not work properly anymore after upgrading jboss from 4.0.4 to 4.2.1.

Raised the same issue in the JBoss forum but they have replied that it is a spring bug that it is trying to synchronise a inactive transaction.

For more information Please refer the below links.

http://jira.jboss.com/jira/browse/JBAS-4972

http://www.jboss.com/index.html?module=bb&op=viewtopic&t=118261

I have also raised it in the spring forum Please refer the below link

http://forum.springframework.org/showthread.php?t=27867

Can you please help me out in this as this seems to be very critical.

Thanks,

Kavipriya

Affects: 2.0.2, 2.5 RC1

Issue Links:

#8862 Transaction not rolling back with JBoss 4.2.x

#8801 Propagation REQUIRES_NEW fails on JBoss Application Server 4.2.1 when keeping a JDBC Connection handle

Backported to: 2.0.8