Hi all,
I'm still attempting to update test code from 3.0.1 to 3.1 and am running
into a new set of issues. In 3.0 I was able to define a single
persistence.xml with a persistence unit defining a transaction-type of JTA.
When running with the embedded EJB container, I was able to lookup EJBs
that had entity managers injected and use the entity managers inside the
EJBs with container managed transactions. I was ALSO able to lookup the JTA
UserTransaction object outside of an EJB, and create an entity manager using
the javax.persistence.Persistence class which would look something like the
following:
UserTransaction userTransaction =
(UserTransaction)context.lookup("UserTransaction");
EntityManager entityManager =
Persistence.createEntityManagerFactory("default").createEntityManager();
This entityManager was able to work alongside of the userTransaction to
execute JTA-based user managed transactions and JPA persistence:
userTransaction.begin();
entityManager.joinTransaction();
entityManager.persistence(someEntity);
userTransaction.commit();
So the transaction management and entity persistence seemed to be integrated
nicely in the embedded container for 3.0. As of 3.1, the code now generates
exceptions when trying to have the entity manager join the transaction:
javax.persistence.TransactionRequiredException:
Exception Description: No transaction is currently active
at
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.throwCheckTransactionFailedException(EntityTransactionWrapper.java:113)
at
org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.checkForTransaction(EntityTransactionWrapper.java:50)
at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.checkForTransaction(EntityManagerImpl.java:1666)
at
org.eclipse.persistence.internal.jpa.EntityManagerImpl.joinTransaction(EntityManagerImpl.java:1698)
It appears to be the case that the persistence context and transaction
manager can no longer find each other in 3.1.
Do I have to do something extra as of v3.1 to get the persistence contexts
integrated with the transaction manager?
Thanks
- Phillip