Matthew Pitts created ARIES-1393:
------------------------------------

             Summary: XAJpaTemplate calls EntityManager#joinTransaction 
regardless of desired TransactionType
                 Key: ARIES-1393
                 URL: https://issues.apache.org/jira/browse/ARIES-1393
             Project: Aries
          Issue Type: Bug
          Components: JPA
    Affects Versions: jpa-2.2.0
         Environment: jpa.support-2.2.0-SNAPSHOT
eclipselink 2.5.2.
            Reporter: Matthew Pitts


When calling txExpr methods with TransactionType.Supports on OSGi-exposed 
JpaTemplate services with a JTA setup a TransactionRequired [1] exception is 
thrown when no existing transaction is present.

The logic in XAJpaTemplate#txExpr is calling EntityManager#joinTransaction() 
regardless of whether there is a current global transaction. So for situations 
where users want to 'support' running within an existing global transaction, 
but not create a new one if one doesn't exist, em.joinTransaction() is still 
being called which results in the exception.

[1] Caused by: javax.persistence.TransactionRequiredException:
Exception Description: No externally managed transaction is currently active 
for this thread
        at 
org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper.throwCheckTransactionFailedException(JTATransactionWapper.java:94)
 ~[org.eclipse.persistence.jpa.jar:na]
        at 
org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper.checkForTransaction(JTATransactionWrapper.java:54)
 ~[org.eclipse.persistence.jpa.jar:na]
        at 
org.eclipse.persistence.internal.jpa.transaction.JTATransactionWrapper.registerIfRequired(JTATransactionWrapper.java:131)
 ~[org.eclipse.persistence.jpa.jar:na]
        at 
org.eclipse.persistence.internal.jpa.EntityManagerImpl.joinTransaction(EntityManagerImpl.java:2081)
 ~[org.eclipse.persistence.jpa.jar:na]
        at 
org.apache.aries.jpa.support.impl.XAJpaTemplate.txExpr(XAJpaTemplate.java:57) 
~[na:na]
        ... 20 common frames omitted





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to