java.lang.ClassCastException: com.ibm.ws.tx.jta.UserTransactionImpl incompatible with javax.transaction.TransactionManager
shareefzafar Apr 12, 2017 3:33 AMHi,
I am setting the UserTransaction to Environment.And passing it to JBPM to get the session. On execution of below line getting the error from drools(using drools 6.5.0-Final)
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(1, kbase, null, env);
drools internally using javax.transaction.TransactionManager and which is throwing incompatible error.
Kindly do needful.
Code Snippet:
static StatefulKnowledgeSession ksession = null;
KnowledgeBase kbase = null;
- InitialContext ctx = new InitialContext();
- UserTransaction tm = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.TRANSACTION_MANAGER, tm);
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
kbase = readKnowledgeBase();
ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(1, kbase, null, env);
Error Log:
emf::: org.hibernate.ejb.EntityManagerFactoryImpl@486dab07
env::: org.drools.impl.EnvironmentImpl@9843be15
User Transaction::org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader@1a816186
Code Location::file:/usr1/wasbase8.5.5/plugins/javax.j2ee.jta.jar
kbase::: org.drools.impl.KnowledgeBaseImpl@2a8875c8
sessId::: 6
java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:115)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadStatefulKnowledgeSession(KnowledgeStoreServiceImpl.java:83)
at org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(JPAKnowledgeService.java:131)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:100)
... 44 more
Caused by: java.lang.ClassCastException: com.ibm.ws.tx.jta.UserTransactionImpl incompatible with javax.transaction.TransactionManager
at org.drools.persistence.jta.JtaTransactionManager.<init>(JtaTransactionManager.java:75)
at org.drools.persistence.SingleSessionCommandService.initTransactionManager(SingleSessionCommandService.java:303)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:183)
... 49 more
Thanks
Zafar