如何在websphere8.5.0.0中获取UserTransaction?

时间:2015-12-29 07:06:29

标签: java hibernate websphere-8 ejb-2.x

我已经在Websphere 8.5.0.0服务器中部署了我的EJB应用程序,但在启动时我面临以下异常:

 **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

我已经尝试了各种解决方案,可以将JNDI名称更改为&#34; jta / UserTransaction&#34; ,&#34; UserTransaction&#34;和&#34; java:comp / UserTransaction&#34;但他们都没有工作。 是webpshere-hibernate兼容性问题还是特定于websphere 8.5.0.0? 请建议可能的解决方案。提前谢谢。

1 个答案:

答案 0 :(得分:1)

看起来,您需要将WAS升级到FIX PACK 2,COMP/USERTRANSACTION" NOT FOUND IN CONTEXT "JAVA

或者如果您犯了这个错误,请在错误的地方Transaction and Websphere - problems

进行查找