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

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: EAP_EWP 5.1.1
    • Fix Version/s: TBD EAP 5
    • Component/s: Hibernate
    • Labels:
      None
    • Affects:
      Release Notes
    • Release Notes Text:
      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.
    • Release Notes Docs Status:
      Documented as Resolved Issue
    • Docs QE Status:
      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();

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                stliu Strong Liu
                Reporter:
                alessandrolt Alessandro Lazarotti
                Writer:
                Russell Dickenson
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: