Results 1 to 3 of 3

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

  1. #1
    Join Date
    Aug 2005
    Posts
    8

    Default 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. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Is it possible to see the full stacktrace? If you want to know what changed, it might be worth checking out the change logs.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Aug 2005
    Posts
    8

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •