Announcement Announcement Module
Collapse
No announcement yet.
Spring 1.1.5 -> 1.2.6 : Tx marked as rollback-only Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 1.1.5 -> 1.2.6 : Tx marked as rollback-only

    Hi,

    I had JUnit Spring Mock code, using Spring 1.1.5, Hibernate 2.1.x. It was working fine.
    I moved to Spring 1.2.6 (actually changed 2 jars : spring, and spring-mock, I'm not using the "full" jars, I include all dependencies one by one). Now I get : "Transaction has been rolled back because it has been marked as rollback-only".

    My TestCase extends : AbstractTransactionalDataSourceSpringContextTests
    My TransactionManager is : org.springframework.orm.hibernate.HibernateTransac tionManager

    I tried to dig/debug through the TransactionManager and the like, I finally end up lost with all the SessionHold, SmartTransactionObject, and the like.

    What could have possibly changed concerning transaction management, between Spring 1.1.5 and 1.2.6 ? Any idea what else I should look for ?

  • #2
    Is it possible to see the full stacktrace? If you want to know what changed, it might be worth checking out the change logs.

    Comment


    • #3
      I found the answer here :
      http://forum.springframework.org/showthread.php?t=16642

      Something actually changed in Spring 1.2.1 : they added an explicit exception when a commit() was attempted on a transaction that was marked as "rollback" by previous calls.

      Problem occur when doing things like :

      try {
      service.somethingIExpectToFail();
      fail()
      } catch (ExpectedException e) {
      // expected.
      // here I think all is ok, except that transaction is marked rollback
      }

      service.somethingIExceptToSucceed(); // <-- this fails at commit because previous call marked the whole transaction as rollback.

      All comes from the behaviour that commit/rollbacks are attempted by the AOP Transaction Manager around services that participated in an already existing transaction when marked as PROPAGRATION_REQUIRED. I wouldn't except a commit() to be called "during" the transaction.

      Comment

      Working...
      X