我正在尝试在ESB服务器上设置应用程序。我们有一个OSGi包,其中包含我们需要的所有依赖项,但我们现在遇到了一个奇怪的问题。在运行时,服务器将无法为我们的应用服务器实例化CXF客户端。堆栈跟踪是
java.lang.LinkageError: loader constraint violation: when resolving method "javax.xml.ws.Service.<init>(Ljava/net/URL;Ljavax/xml/namespace/QName;)V" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, mil/sddc/fltmgt/ws/api/FleetManagementWSServiceService, and the class loader (instance of <bootloader>) for resolved class, javax/xml/ws/Service, have different Class objects for the type <init> used in the signature
at mil.sddc.fltmgt.ws.api.FleetManagementWSServiceService.<init>(FleetManagementWSServiceService.java:39)
at mil.sddc.ibs.mediators.fleetManagement.TestClient.mediate(TestClient.java:28)
at org.apache.synapse.mediators.ext.ClassMediator.mediate(ClassMediator.java:78)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.rest.Resource.process(Resource.java:297)
at org.apache.synapse.rest.API.process(API.java:341)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:76)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:63)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:344)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:168)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
我之前没有看过这个特定的堆栈跟踪,但看起来WSO2的启动类加载器都提供了FleetManagementWSServiceService,Service或两者的实例,导致冲突。
听起来像WSO2的启动类加载器,我的OSGi包的类加载器都提供FleetManagementWSServiceService,Service或两者。据推测,它必须是Service,因为即使我不小心将这个类放在一个jar中,该类将被启动类加载器拾取,OSGi包中的那个应该始终受到青睐。
另一个类javax.xml.ws.Service包含在Java运行时以及其他一些jar中。我在服务器上的endorsed文件夹中找到了一个带有它的geronimo jaxws jar并删除它以防万一,但这不会影响构建。
答案 0 :(得分:1)
我假设你并行安装了CXF和Axis2。这不行。堆栈跟踪显示Axis2被触发以启动客户端,但它与已安装的CXF冲突。
所以解决方案是只安装Axis2或CXF。
答案 1 :(得分:0)
当我发布这个时,我认为问题来自于缺少服务器上的依赖项,但事实证明我们实际上缺少OSGi包中的依赖项。通过包含一个包含javax.xml.ws.Service的geronimo-jaxws jar,这个问题就解决了。
接近我可以说Axis2和CXF的问题是红色的鲱鱼。捆绑包中仍然存在CXF依赖关系,服务器仍在使用Axis2来调用我们的类。尽管如此,请提供帮助!