Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-7072

HHH-6599 - Hibernate mark as rollback even for no transaction requests

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • TBD EAP 5
    • EAP_EWP 5.1.1
    • Hibernate
    • None
    • Release Notes
    • Hide
      If Hibernate's EntityManager was used in a CMT Bean and a GenericJDBCException occurred, Hibernate would initiate a rollback even if there was no active transaction, resulting in the exception:

      <screen>
      <org.hibernate.ejb.AbstractEntityManagerImpl> Unable to mark for rollback on PersistenceException:
      java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] No such transaction!
      </screen>

      This issue has been resolved so a rollback is no longer initiated in these circumstances.
      Show
      If Hibernate's EntityManager was used in a CMT Bean and a GenericJDBCException occurred, Hibernate would initiate a rollback even if there was no active transaction, resulting in the exception: <screen> <org.hibernate.ejb.AbstractEntityManagerImpl> Unable to mark for rollback on PersistenceException: java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] No such transaction! </screen> This issue has been resolved so a rollback is no longer initiated in these circumstances.
    • Documented as Resolved Issue
    • NEW

    Description

      When used a Hibernate EntityManager in a CMT Bean and a GenericJDBCException is launched, Hibernate will try a rollback even if there is not an active transaction, generating the exception:

      <org.hibernate.ejb.AbstractEntityManagerImpl> Unable to mark for rollback on PersistenceException:
      java.lang.IllegalStateException: [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] [com.arjuna.ats.internal.jta.transaction.arjunacore.nosuchtx] No such transaction!
      at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.setRollbackOnly(BaseTransaction.java:188)
      at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.setRollbackOnly(BaseTransactionManagerDelegate.java:135)
      at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:440)
      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:595)
      at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
      at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:74)

      ... hiding the original "Caused By" from the other Exception (GenericJDBCException).

      As example, a case where some error in runtime happens in a database procedure execution and the bean method is annotated as "NOT_SUPPORTED" transaction, this behaviour will happen and the original exception will be lost, the root exception is overridden by "No such transaction" exception and so the cause is not reported in log files. Hibernate should not try a rollback if there is not a transaction.

      Fixing it is necessary update the method:
      "protected void markAsRollback()"

      .. from org.hibernate.ejb.AbstractEntityManagerImpl.java
      That method just check no CMT JTA transaction:

      "if ( tx.isActive() )

      { tx.setRollbackOnly(); }

      "

      The same check is necessary for CMT JTA using transactionManager.getStatus and looking if it is different than Status.NoTransaction.
      This check should be done above the code that call transactionManager.setRollbackOnly();

      Attachments

        Activity

          People

            shaozliu Strong Liu(刘少壮) (Inactive)
            rhn-support-alazarot Alessandro Lazarotti
            Russell Dickenson Russell Dickenson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: