C. Dev
C. Dev

Reputation: 11

How to obtain UserTransaction in websphere8.5.0.0?

I had deployed my EJB application in Websphere 8.5.0.0 server but while starting it I am facing below exception:

 **CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method "getABCMethod" on bean "BeanId(ABC-ear#ABC-ejb-3.9.jar#ABC, null)". Exception data: org.hibernate.TransactionException: Could not find UserTransaction in JNDI [java:comp/UserTransaction]**
    at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:173)
    at org.hibernate.transaction.JTATransactionFactory.createTransaction(JTATransactionFactory.java:149)
    at org.hibernate.jdbc.JDBCContext.registerSynchronizationIfPossible(JDBCContext.java:213)
    at org.hibernate.jdbc.JDBCContext.<init>(JDBCContext.java:103)
    at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:256)
    at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:670)
    at org.hibernate.context.JTASessionContext.buildOrObtainSession(JTASessionContext.java:152)
    at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:111)
    at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687)

**Caused by: javax.naming.NameNotFoundException: Name "comp/UserTransaction" not found in context "java:".**
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1228)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1141)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)
    at org.hibernate.transaction.JTATransactionFactory.getUserTransaction(JTATransactionFactory.java:163)
    ... 39 more

I had already tried various solution available as changing JNDI name to "jta/UserTransaction" , "UserTransaction" and "java:comp/UserTransaction" but none of them working. Is it webpshere-hibernate compatibility issue or websphere 8.5.0.0 specific? Please suggest what could be the solution. Thanks in advance.

Upvotes: 1

Views: 1734

Answers (1)

Sabir Khan
Sabir Khan

Reputation: 10142

Looks like, you need to upgrade WAS to FIX PACK 2 , COMP/USERTRANSACTION" NOT FOUND IN CONTEXT "JAVA

or if you might be making this mistake , doing lookup at incorrect place Transaction and Websphere - problems

Upvotes: 1

Related Questions