I am upgrading entity beans in our application from EJB 2.0 to 3.0 version. I am using openjpa version 1.2.2 on weblogic server(10.3.0) and transaction type will be JTA.
I am facing the below error while committing the transaction post persisting the entity:
javax.transaction.SystemException: Illegal state (Expected: PrePrepared). BEA1-0A15322BC6A35D331713 at weblogic.transaction.internal.TransactionImpl.abortUnsync(TransactionImpl.java:1134) at weblogic.transaction.internal.ServerTransactionImpl.globalPrepare(ServerTransactionImpl.java:2172) at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:270) at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:230) at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:283) at weblogic.transaction.internal.TransactionManagerImpl.commit(TransactionManagerImpl.java:277) at com.bt.cp.entities.EntityBeansMultiThreadTest$Loader.call(EntityBeansMultiThreadTest.java:104) at com.bt.cp.entities.EntityBeansMultiThreadTest$Loader.call(EntityBeansMultiThreadTest.java:78) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) at java.lang.Thread.run(Thread.java:619)
Below is the code snippet which causes this error:
public Boolean call() throws Exception {
EntityManager entityManager = entityManagerSingleton.createEntityManager();
UserTransaction tx = entityManagerSingleton.createTransaction();
try {
tx.begin();
// Join the EntityManager operations to this UserTransaction
entityManager.joinTransaction();
entityManager.persist(new Party());
tx.commit();
} catch(Exception e) {
e.printStackTrace()
}
return true;
}
Below is my persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
<persistence-unit name="testDataSource" transaction-type="JTA">
<jta-data-source>testDataSource</jta-data-source>
<class>test.Party</class>
<class>
.........................
</class>
<properties>
<property name="openjpa.QueryCache" value="true(CacheSize=1000)"/>
</properties>
</persistence-unit>
</persistence>
This error is not seen with openjpa version 1.1.0(part of weblogic 10.3.0). However, there is a major bug with version 1.1.0(https://issues.apache.org/jira/browse/OPENJPA-466) and hence, I am using version 1.2.2.
How can this issue be resolved? Anybody has any pointers on this. Any help is appreciated.