Results 1 to 6 of 6

Thread: Transaction has been rolled back b/c marked as rollback-only

  1. #1
    Join Date
    Dec 2005
    Location
    Boulder, Colorado, USA
    Posts
    6

    Default Transaction has been rolled back b/c marked as rollback-only

    I am experiencing strange problems with one of my transactional methods. Whenever I create (vs. update) a new object I get this exception/message:

    "Transaction has been rolled back because it has been marked as rollback-only"

    The exact same code works if I am updating the same row with a different status, but fails when I am creating the object/row.

    Also, sometimes I can force the object to commit by committing the transaction myself. But sometimes my explicit commit does not work.

    I am accessing the service marked as transactional via JMS (just a queue with listener; no EJB anywhere in the app). I have tried both transactional and non-transactional sessions, but I consistently fail with either approach.

    Here are my service transaction settings:

    Code:
    <property name="transactionAttributes">
      <props>
        <prop key="save*">PROPAGATION_REQUIRED</prop>
        <prop key="remove*">PROPAGATION_REQUIRED</prop>
        <prop key="*">PROPAGATION_REQUIRED</prop>
      </props>
    </property>
    We are running on Oracle 10 AS (as_windows_x86_101202_disk1.zip).

    Thanks in advance for your help!

    Vaughn

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    <prop key="save*">PROPAGATION_REQUIRED</prop>
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    You can use only the last line (there are no differences in configuration).
    The behavior you described sounds like there might be a problem
    with the oracle driver (there have been some reports on the forum).
    Enable logging and see what's going on. If you can't resolve the
    issue post the exception stack trace plus some code and configuration.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Dec 2005
    Location
    Boulder, Colorado, USA
    Posts
    6

    Default

    Quote Originally Posted by costin
    You can use only the last line (there are no differences in configuration).
    Ok, thanks.

    Quote Originally Posted by costin
    The behavior you described sounds like there might be a problem
    with the oracle driver (there have been some reports on the forum).
    Enable logging and see what's going on. If you can't resolve the
    issue post the exception stack trace plus some code and configuration.
    I have turned on a dizzying array of debug level logging and it turns up no exceptions other than the one that I catch. Is it possible that I need to intercept a low-level exception? I would think that at a minimum it would display in the log.

    I have read a bit about the UnexpectedRollbackException, which is the exception behind the message. I really don't see other exceptions. I am using what some have called an inner and outer transaction (service marked as required and Hibernate DAO also commits explicitly), and I have also tried the service-only commit. I receive the UnexpectedRollbackException just as the service method is returning. This seems to be the correct occurance for UnexpectedRollbackException from what I have read, but it is only supposed to get thrown if I have an transactional exception behind the service layer. Strange...

    Also, FWIW, this app is not new. We have dozens of services running successfully, and we have other methods in the same service & DAO that are working well.

    Anyway, here is my stack trace:

    Code:
    [#appname#] 2005-12-27 17:31:20,016 ERROR [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] FeatureConnectorRequestProcessor.processRequest(67) | FeatureConnectorRequestProcessor#processRequest (): Failed to mark feature pending for: FEATURE Connector Request: id=9898 number=1 date=Wed Dec 28 00:00:00 EST 2005
    org.springframework.transaction.UnexpectedRollbackException: Transaction has been rolled back because it has been marked as rollback-only
            at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:416)
            at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:258)
            at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
            at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
            at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
            at $Proxy17.markTxnShiftPending(Unknown Source)
            at com.company.appname.service.feature.impl.FeatureConnectorRequestProcessor.processRequest(FeatureConnectorRequestProcessor.java:46)
            at com.company.appname.service.feature.impl.FeatureConnectorQueueMessageListener.onMessage(FeatureConnectorQueueMessageListener.java:78)
            at com.evermind.server.jms.EvermindSession.doListener(EvermindSession.java:1327)
            at com.evermind.server.jms.EvermindSession.handleMessage(EvermindSession.java:1143)
            at com.evermind.server.jms.EvermindMessageConsumer.handleMessage(EvermindMessageConsumer.java:445)
            at com.evermind.server.jms.EvermindMessageConsumer.access$300(EvermindMessageConsumer.java:40)
            at com.evermind.server.jms.EvermindMessageConsumer$1.run(EvermindMessageConsumer.java:399)
            at java.lang.Thread.run(Thread.java:534)
    Much Thanks!

    Vaughn

  4. #4
    Join Date
    Dec 2005
    Location
    Boulder, Colorado, USA
    Posts
    6

    Default

    Oops!

    I had so much logging that I couldn't see the logs for the trees

    Code:
    [#appname#] 2005-12-27 17:31:19,516 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] RuleBasedTransactionAttribute.rollbackOn(119) | Applying rules to determine whether transaction should rollback on org.springframework.orm.ObjectRetrievalFailureException: Object of class [com.company.appname.model.Shift] with identifier [com.company.appname.model.ShiftPK@119bf16[date=Wed Dec 28 00:00:00 EST 2005,id=9898,num=1]]: not found
    [#appname#] 2005-12-27 17:31:19,516 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] RuleBasedTransactionAttribute.rollbackOn(137) | Winning rollback rule is: null
    [#appname#] 2005-12-27 17:31:19,516 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] RuleBasedTransactionAttribute.rollbackOn(143) | No relevant rollback rule found: applying superclass default
    [#appname#] 2005-12-27 17:31:19,563 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] TransactionAspectSupport.doCloseTransactionAfterThrowing(272) | Invoking rollback for transaction on com.company.appname.service.FeatureManager.getShift due to throwable [org.springframework.orm.ObjectRetrievalFailureException: Object of class [com.company.appname.model.Shift] with identifier [com.company.appname.model.ShiftPK@119bf16[date=Wed Dec 28 00:00:00 EST 2005,id=9898,num=1]]: not found]
    [#appname#] 2005-12-27 17:31:19,563 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] AbstractPlatformTransactionManager.rollback(502) | Setting existing transaction rollback-only
    [#appname#] 2005-12-27 17:31:19,563 DEBUG [Listener[Oc4jJMS.MessageConsumer.VVERNONLT.149b290:1086e45a15a:-8000.63]] HibernateTransactionManager.doSetRollbackOnly(528) | Setting Hibernate transaction on session [org.hibernate.impl.SessionImpl@104d7f2] rollback-only
    Answer is: I test for the existence of the object that I am about to insert in the database before I attempt to insert. I want to see a failure on that get, but unfortunately the failure marks my entire transaction as rollback-only. So mu subsequent insert fails. This makes sense. I will just have to catch a duplicate key constraint exception to see if it already exists on insert instead of testing for existence before insert.

    Comment: This Spring stuff really works and your forum history is very helpful.

    Thanks!

    Vaughn

  5. #5

    Default

    There are no errors when using hibernate, because it closes the connection and creates a new access to each

    The error occurs only when using JDBC:
    >>org.springframework.transaction.UnexpectedRollba ckException: Transaction rolled back because it has been marked as rollback-only

    I hope I have helped someone,

    code JDBC:
    super.getJdbcTemplate().execute(sql);

    Simply adjust your query and delete temporary tables when using them:
    drop all temporary tables #temp:

  6. #6
    Join Date
    Jan 2012
    Posts
    6

    Thumbs up

    Or it might turn out that your disk is full ...

    Thank you for this post, it contained the hint I needed.


    Business School Rankings
    Best MBA Programs

Posting Permissions

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