JAXB 问题 -- 类......在此上下文中,其任何超类均未知
这两天我一直在尝试解决这个问题,但没有成功!
我的 Web 服务以及客户端在我的机器上运行良好(我正在 Weblogic 10.3.2 上测试应用程序,与我们的 DEV 环境相同)。但每当我将应用程序部署到 DEV 时,都会出现以下异常。
我的假设是类加载器正在加载“旧”jar 文件,这些文件不支持我当前的应用程序代码,但我无法弄清楚如何解决这个问题。
我尝试了很多方法,从在我的ear文件中使用“prefer-application-packages”,到创建“endorsed”目录并将其包含在我的类路径中,但没有任何效果。 (我已将 axis2 和 jaxb jar 都包含在“endorsed”目录中)。
那里有人有任何可能的解决方案吗?我应该“覆盖”哪些 jar 文件?你认为这件事失败在哪里?
任何帮助表示赞赏!
开发配置:
Weblogic 10.3.2
java.version = 1.6.0_14 java.vm.info = compiled mode java.vm.name = BEA JRockit(R) java.home = /app/platform/jrockit/3.1.2/jre java.class.path = /app/platform/jrockit/3.1.2/lib/endorsed/jaxb-impl-2.2.2.jar::/app/platform/wls/10.3.2/patch_wls1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/app/platform/jrockit/3.1.2/lib/tools.jar:/app/platform/wls/10.3.2/utils/config/10.3/config-launch.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/weblogic_sp.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/weblogic.jar:/app/platform/wls/10.3.2/modules/features/weblogic.server.modules_10.3.2.0.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/webservices.jar:/app/platform/wls/10.3.2/modules/org.apache.ant_1.7.0/lib/ant-all.jar:/app/platform/wls/10.3.2/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar:/app/platform/wls/10.3.2/wlserver_10.3/common/eval/pointbase/lib/pbclient57.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/xqrl.jar
Caused By: javax.xml.bind.JAXBException: class com.comcast.cet.web.service.routing.lb.f5.impl.GetWipInfoForSpecificPoolMemberRequest nor any of its super class is known to this context. at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:605) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:486) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:320) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:249) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.axis2.datasource.jaxb.JAXBDSContext$1.run(JAXBDSContext.java:388) at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:76) at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshalByElement(JAXBDSContext.java:369) at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshal(JAXBDSContext.java:339) at org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._outputFromBO(JAXBBlockImpl.java:189) at org.apache.axis2.jaxws.message.impl.BlockImpl.outputTo(BlockImpl.java:370) at org.apache.axis2.jaxws.message.impl.BlockImpl.serialize(BlockImpl.java:294) at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:965) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245) at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79) at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:554) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:118) at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:82) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:317) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:159) at $Proxy84.getWipInfoForSpecificPoolMember(Unknown Source) at com.comcast.cet.web.service.routing.lb.LoadBalancerMain.getWipInfoForPoolMember(LoadBalancerMain.java:73) at com.comcast.cet.web.controllers.rpc.RoutingServiceImpl.getWipInfoForSpecificFarm(RoutingServiceImpl.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:544) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:504) at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.processCall(RoutingServiceRpcController.java:64) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.handleRequest(RoutingServiceRpcController.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
I've been trying to figure this problem out for the last 2 days already, but to no avail!
My webservice, as well as the client, are working fine on my machine (I'm testing the applicaiton on Weblogic 10.3.2, same as our DEV environment). But whenever I deploy the app to DEV, the below exception shows up.
My assumption is that the classloaders are loading "old" jar files, which don't support my current application code, but I have no way of figuring out how to solve this issue.
I've tried many things, from using the 'prefer-application-packages' in my ear file, to creating the "endorsed" directory and including that in my classpath, but nothing works. (I've included both the axis2 and jaxb jars in the 'endorsed' dir).
Does anybody out there have any possible solution to this? Which jar files should I "overwrite"? Where do you think this is failing?
Any help is appreciated!!!
DEV configuration:
Weblogic 10.3.2
java.version = 1.6.0_14 java.vm.info = compiled mode java.vm.name = BEA JRockit(R) java.home = /app/platform/jrockit/3.1.2/jre java.class.path = /app/platform/jrockit/3.1.2/lib/endorsed/jaxb-impl-2.2.2.jar::/app/platform/wls/10.3.2/patch_wls1032/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/app/platform/jrockit/3.1.2/lib/tools.jar:/app/platform/wls/10.3.2/utils/config/10.3/config-launch.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/weblogic_sp.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/weblogic.jar:/app/platform/wls/10.3.2/modules/features/weblogic.server.modules_10.3.2.0.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/webservices.jar:/app/platform/wls/10.3.2/modules/org.apache.ant_1.7.0/lib/ant-all.jar:/app/platform/wls/10.3.2/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar:/app/platform/wls/10.3.2/wlserver_10.3/common/eval/pointbase/lib/pbclient57.jar:/app/platform/wls/10.3.2/wlserver_10.3/server/lib/xqrl.jar
Caused By: javax.xml.bind.JAXBException: class com.comcast.cet.web.service.routing.lb.f5.impl.GetWipInfoForSpecificPoolMemberRequest nor any of its super class is known to this context. at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:605) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:486) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:320) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:249) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.apache.axis2.datasource.jaxb.JAXBDSContext$1.run(JAXBDSContext.java:388) at org.apache.axis2.java.security.AccessController.doPrivileged(AccessController.java:76) at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshalByElement(JAXBDSContext.java:369) at org.apache.axis2.datasource.jaxb.JAXBDSContext.marshal(JAXBDSContext.java:339) at org.apache.axis2.jaxws.message.databinding.impl.JAXBBlockImpl._outputFromBO(JAXBBlockImpl.java:189) at org.apache.axis2.jaxws.message.impl.BlockImpl.outputTo(BlockImpl.java:370) at org.apache.axis2.jaxws.message.impl.BlockImpl.serialize(BlockImpl.java:294) at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.internalSerialize(OMSourcedElementImpl.java:691) at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:965) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.serializeInternally(SOAPEnvelopeImpl.java:283) at org.apache.axiom.soap.impl.llom.SOAPEnvelopeImpl.internalSerialize(SOAPEnvelopeImpl.java:245) at org.apache.axiom.om.impl.llom.OMSerializableImpl.serializeAndConsume(OMSerializableImpl.java:193) at org.apache.axis2.transport.http.SOAPMessageFormatter.writeTo(SOAPMessageFormatter.java:79) at org.apache.axis2.transport.http.AxisRequestEntity.writeRequest(AxisRequestEntity.java:84) at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499) at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:557) at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199) at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:76) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:400) at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:225) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:438) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:402) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:554) at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.doInvoke(AxisInvocationController.java:118) at org.apache.axis2.jaxws.core.controller.impl.InvocationControllerImpl.invoke(InvocationControllerImpl.java:82) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:317) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:159) at $Proxy84.getWipInfoForSpecificPoolMember(Unknown Source) at com.comcast.cet.web.service.routing.lb.LoadBalancerMain.getWipInfoForPoolMember(LoadBalancerMain.java:73) at com.comcast.cet.web.controllers.rpc.RoutingServiceImpl.getWipInfoForSpecificFarm(RoutingServiceImpl.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:562) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:544) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:504) at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.processCall(RoutingServiceRpcController.java:64) at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:243) at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62) at com.comcast.cet.web.controllers.rpc.RoutingServiceRpcController.handleRequest(RoutingServiceRpcController.java:41) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426) at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3592) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2202) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2108) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1432) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,如果您在 weblogic 或 websphere 上运行代码(我使用的是前者),快速解决方案就是从 Axis2 切换到 Apache CXF。原因是这些应用程序服务器将 axis 捆绑到它们的 RTE 中,因此当您的托管服务器启动时,首先读取与 weblogic 捆绑的 axis 库,而不是您的 axis 库。您可以使用许多“技巧”来完成这项工作:
在上述所有情况下,代码仍然无法正常运行,所以我认为合适的唯一选项是从 axis2 切换到 cxf,这不被 weblogic 捆绑,因此没有“干扰”!如果您使用的是 weblogic,则必须将以下内容添加到服务器“启动”选项中:
这是 weblogic 中的一个已知问题。
这是我必须包含的 cxf maven 依赖项(我删除了所有的 axis 和 axiom 依赖项)
Ok, the quick solution is simply to switch from Axis2 to Apache CXF if you're running your code on weblogic or websphere (I was using the former). The reason for that is that these application servers bundle axis into their RTE, so when you managed server starts up, the axis libraries that are bundled with weblogic are read in first, rather then your axis libraries. There are a lot of "hacks" you can use/do to make this work:
In all of the above cases, the code still didn't function properly, so the only option that I saw fit was to switch from axis2 to cxf, which isn't bundled by weblogic, therefore no "interference"! If you are using weblogic, then you'll have to add the following to the server 'startup' options:
This is a known issue in weblogic.
Here are the cxf maven dependencies I had to include (I removed ALL of the axis and axiom dependencies)