0

我有一个使用 eclipselink2.0 作为 JPA 提供程序的宁静 Web 服务,部署在 WAS 上,而 7.0.00.19 带有 OSGI 和 JPA2.0 功能包。我为指向这些 jar 文件位置的应用程序创建了一个共享库:

  • c:\bacpext\eclipselink-javax.persistence-2.0.jar
  • c:\bacpext\eclipselink-2.0.2.jar

尝试访问资源 uri 会引发以下异常

[10/11/11 15:53:18:151 CEST]     FFDC Exception:java.lang.ClassCastException SourceId:com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch ProbeId:448 Reporter:com.ibm.ws.webcontainer.servlet.ServletWrapperImpl@2f412f41
java.lang.ClassCastException: com.ibm.ws.jpa.management.JPATxEntityManager incompatible with javax.persistence.EntityManager
    at com.tavia.service.PersistenceService.<init>(PersistenceService.java:39)
    at com.tavia.service.PersistenceService.<init>(PersistenceService.java:19)
    at com.tavia.service.PersistenceService$1.initialValue(PersistenceService.java:29)
    at com.tavia.service.PersistenceService$1.initialValue(PersistenceService.java:26)
    at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:152)
    at java.lang.ThreadLocal.get(ThreadLocal.java:142)
    at com.tavia.service.PersistenceService.getInstance(PersistenceService.java:52)
    at com.tavia.service.GltmMisCodesResource.get(GltmMisCodesResource.java:64)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:149)
    at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:67)
    at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:259)
    at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:83)
    at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:133)
    at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:71)
    at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:990)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:941)
    at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:932)
    at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:384)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:451)
    at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:632)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3935)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)

关于什么可能是错的任何想法?

4

1 回答 1

0

PersistenceService 似乎已获得对由 WAS 运行时 (JPATxEntityManager) 创建的 EM 代理的引用,但它正试图将其转换为已被 eclipselink-javax.persistence-2.0.jar 覆盖的 javax.persistence.EntityManager . 在不知道您要做什么的情况下,其中之一就是问题:

  1. 您不应包含 eclipselink-javax.persistence-2.0.jar 来覆盖 javax.persistence;您应该使用 WebSphere 已经提供的持久性 API 类。
  2. ...或者您出于某种原因确实想要覆盖持久性 API 类。在这种情况下,您应该更改获取 EM 的方式以确保它不使用注入或 java:comp 查找,这将始终返回与覆盖的 javax.persistence API 不兼容的 JPATxEntityManager。
于 2011-10-11T16:41:42.773 回答