1

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.

C. Dev
  • 11
  • 2

1 Answers1

1

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

Sabir Khan
  • 9,826
  • 7
  • 45
  • 98
  • Thanks for your reply Sabir. But lookup is correct I checked. And if I am changing TransactionFactory from 'JTATransactionFactory' to 'JDBCTransactionFactory' then it is working fine. But I am unable to find the reason why its working with JDBC not with JTA? – C. Dev Dec 30 '15 at 08:36
  • how you deploy your EJB to server , via manual copy , WAS console or IDE ? if IDE, IDE name? – Sabir Khan Dec 30 '15 at 09:05
  • I am deploying EAR file via WAS console. – C. Dev Dec 30 '15 at 09:47
  • Also I want to ask if it is WAS8.5.0.0 issue then how come is it working with JDBCTransactionFactory.... – C. Dev Dec 30 '15 at 09:49