应用程序重新启动后 JPA 实体上的 ClassCastException



我们现在使用的是 WebSphere 9,并且某些应用程序的行为与在 WebSphere 8.5.5 中的行为不同。每次我们重新启动应用程序(而不是服务器)时,它们都会停止正常工作,并且日志显示类似于以下内容的异常:

java.lang.ClassCastException: pt.sibs.epms.persistence.entity.EpmsDebugParameters incompatible with pt.sibs.epms.persistence.entity.EpmsDebugParameters

它只发生在 JPA 实体上,我已经检查了类路径以确保 Jar 只被引用一次(我已经导出了应用程序的类加载器信息)。我已经确认当应用程序停止时(通过contextDestroyed ServletContextListener)时,EntityManagerFactory正在关闭。

如前所述,这只发生在 WebSphere 9 上,它在 WebSphere 8.5.5 和 GlassFish 4.1 上运行良好。

有什么想法吗?

编辑 #1

我正在使用 WebSphere Full Profile,它被抛出的异常是:

java.lang.ClassCastException: pt.sibs.epms.persistence.entity.EpmsDebugParameters cannot be cast to pt.sibs.epms.persistence.entity.EpmsDebugParameters
             at pt.sibs.epms.util.logging.LoggerConfiguration.<clinit>(LoggerConfiguration.java:40)
             at pt.sibs.epms.util.logging.LoggerConfiguration.<clinit>(LoggerConfiguration.java)
             at pt.sibs.epms.suppdata.EpmsSuppData.<init>(EpmsSuppData.java:55)
             at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
             at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88)
             at sun.reflect.DelegatingConstructorAccessorImpl.__newInstance(DelegatingConstructorAccessorImpl.java:57)
             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java)
             at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java)
             at java.lang.reflect.Constructor.newInstance(Constructor.java:437)
             at com.ibm.ws.managedobject.internal.ManagedObjectFactoryImpl.createManagedObject(ManagedObjectFactoryImpl.java:65)
             at com.ibm.ws.websvcs.server.WSServiceInstanceFactory.createManagedObject(WSServiceInstanceFactory.java:276)
             at com.ibm.ws.websvcs.server.WSServiceInstanceFactory.createServiceInstance(WSServiceInstanceFactory.java:131)
             at org.apache.axis2.jaxws.server.EndpointController.handleRequest(EndpointController.java:272)
             at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:103)
             at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:161)
             at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:212)
             at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:172)
             at com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:1633)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
             at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
             at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235)
             at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
             at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
             at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
             at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1124)
             at com.ibm.ws.webcontainer.webapp.WebApp.__handleRequest(WebApp.java:4144)
             at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java)
             at com.ibm.ws.webcontainer.webapp.WebAppImpl.handleRequest(WebAppImpl.java:2208)
             at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
             at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1030)
             at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
             at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382)
             at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
             at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532)
             at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318)
             at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289)
             at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1084)
             at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:658)
             at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1820)
             at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
             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:1892)

WebSphere 8.5.5 使用 WSJPA(基于 OpenJPA 构建)作为默认的 JPA 提供程序。但是,从 WebSphere 9 开始,默认的 JPA 提供程序被切换到 EclipseLink。如果您在 WebSphere 8.5.5 上使用 EclipseLink,这意味着您正在为 WebSphere 8.5.5 提供自己的 EclipseLink 库,因为 WebSphere 没有随 EclipseLink 一起提供。

切换到 WebSphere 9 时,应删除 WebSphere 8.5.5 中允许您使用自己的 EclipseLink 的 Eclipselink 库/配置。您发布的错误可能是由于您的应用程序可以看到两个 EclipseLink jar(一个来自您的应用程序/库,一个来自 WebSphere)。

最新更新