EntityListener中的EJB上下文JNDI查找失败@PreUpdate

时间:2016-03-30 09:59:25

标签: java hibernate websphere jpa-2.0 java-ee-6

我有一个JPA EntityListener,我在其中对{em>" java:comp / EJBContext" 进行相同的JNDI查找@PrePersist和{{ 1}}回调方法。虽然在@PreUpdate回调方法中查找成功,但在@PrePersist回调方法期间它仍然失败。

我正在使用Hibernate 4.2.19.Final和Websphere AS 8.5.5.3 build cf031430.01(Java EE 6 / EJB 3.1 / JPA 2.0)。

代码非常简单:

@PreUpdate

这是跟踪:

  

javax.naming.NameNotFoundException:Name" comp / EJBContext"未找到   在上下文" java:"。在   com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1229)   〜[com.ibm.ws.runtime.jar:na] at   com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1142)   〜[com.ibm.ws.runtime.jar:na] at   com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)   〜[com.ibm.ws.runtime.jar:na] at   com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)   〜[com.ibm.ws.runtime.jar:na] at   com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)   〜[com.ibm.ws.runtime.jar:na] at   com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)   〜[com.ibm.ws.runtime.jar:na] at   org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)   〜[na:na] at   javax.naming.InitialContext.lookup(InitialContext.java:422)   〜[na:1.7.0] at   javax.naming.InitialContext.doLookup(InitialContext.java:295)   〜[na:1.7.0] at   my.AuditedEntityListener.lookupSessionContext(AuditedEntityListener.java:29)   [classes /:na] at   my.AuditedEntityListener.getUserName(AuditedEntityListener.java:34)   [classes /:na] at   my.AuditedEntityListener.preUpdate(AuditedEntityListener.java:74)   [classes /:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native   方法)〜[na:1.7.0] at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)   〜[na:1.7.0] at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)   〜[na:1.7.0] at java.lang.reflect.Method.invoke(Method.java:619)   〜[na:2.6(04-09-2014)] at   org.hibernate.ejb.event.ListenerCallback.invoke(ListenerCallback.java:48)   [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:110)   [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:95)   [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:65)   [hibernate-entitymanager-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:334)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:285)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:165)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:230)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:100)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1195)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:404)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.engine.transaction.synchronization.internal.SynchronizationCallbackCoordinatorNonTrackingImpl.beforeCompletion(SynchronizationCallbackCoordinatorNonTrackingImpl.java:109)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   org.hibernate.engine.transaction.synchronization.internal.RegisteredSynchronization.beforeCompletion(RegisteredSynchronization.java:53)   [hibernate-core-4.2.19.Final.jar:4.2.19.Final] at   com.ibm.tx.jta.impl.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:291)   [com.ibm.tx.jta.jar:na] at   com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:153)   [com.ibm.ws.runtime.jar:na] at   com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2382)   [com.ibm.ws.runtime.jar:na] at   com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:586)   [com.ibm.ws.runtime.jar:na] at   com.ibm.tx.jta.impl.TransactionImpl.processCommit(TransactionImpl.java:1028)   [com.ibm.tx.jta.jar:na] at   com.ibm.tx.jta.impl.TransactionImpl.commit(TransactionImpl.java:962)   [com.ibm.tx.jta.jar:na] at   com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:439)   [com.ibm.ws.runtime.jar:na] at   com.ibm.tx.jta.impl.TranManagerSet.commit(TranManagerSet.java:191)   [com.ibm.tx.jta.jar:na] at   com.ibm.ejs.csi.TranStrategy.commit(TranStrategy.java:949)   [com.ibm.ws.runtime.jar:na] at   com.ibm.ejs.csi.TranStrategy.postInvoke(TranStrategy.java:262)   [com.ibm.ws.runtime.jar:na] at   com.ibm.ejs.csi.TransactionControlImpl.postInvoke(TransactionControlImpl.java:567)   [com.ibm.ws.runtime.jar:na] at   com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4491)   [com.ibm.ws.runtime.jar:NA]

1 个答案:

答案 0 :(得分:0)

正如布雷特指出的那样,这是IBM方面的一个漏洞。该问题已在Websphere版本8.5.5.9中修复。

http://www-01.ibm.com/support/docview.wss?uid=swg1PI52932