LinkageError:加载违反约束 [英] LinkageError: loading contraint violation

查看:59
本文介绍了LinkageError:加载违反约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过其他链接错误,但没有一个说明可以用罐子做什么.当我在 Jboss 中部署我的应用程序时它工作正常,但是当我将我的应用程序部署到 websphere 时,我遇到了这个链接错误.可以在此处找到类似的问题:调用 webservice 方法时的 LinkageError 但不确定该怎么做修复它

主要是从 com/ibm/oti/vm/BootstrapClassLoadercom/ibm/ws/classloader/CompoundClassLoader 和共享类 javax/xml 加载/soap/SOAPFault

Caused by: java.lang.LinkageError: 加载约束冲突:加载器com/ibm/oti/vm/BootstrapClassLoader@dda62209"之前启动了一个名为javax/xml/soap/SOAPFault"的不同类型的加载" 由加载程序 "com/ibm/ws/classloader/CompoundClassLoader@fdebcda2" 定义在 com.ibm.oti.vm.VM.findClassOrNull(本机方法)在 com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:63)在 javax.xml.ws.soap.SOAPFaultException.<init>(SOAPFaultException.java:78)在 org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)在 com.sun.proxy.$Proxy118.collectionsInquiryV2(来源不明)

我所拥有的是调用 web 服务的 jsp.从消息中,我看到的唯一罐子来自axis.jar,其中包含类 javax/xml/soap/SOAPFault

这是否意味着我需要从axis.jar 中删除SOAPFault.class?(尝试不起作用,如果删除它,其他网络服务将失败)

解决方案

您的应用程序中有 SOAP API jar 吗?加载约束违反" LinkageError 通常意味着通过两个不同的类加载器对类的重复可见性.我根据堆栈猜测这里发生的是您的应用程序具有 SOAP API 但没有 JAX-WS API.当该 JAX-WS 类引用 SOAP 类时,这意味着您的应用程序中的类可以从两个不同的加载器看到"SOAP API - 直接在本地类加载器中,以及通过 JAX-WS API 间接.

最简单的答案就是去掉应用程序中的任何 SOAP API jar——你可以只依赖服务器中的副本,除非你有一个真正特定的版本需求.或者,您可以将 JAX-WS API jar 添加到应用程序包中,以便应用程序加载自己的 API 副本,而不是从服务器中提取它.

I have seen the other linkage errors but none of them says what can be done with the jars. When I deploy my application in Jboss it works fine, but when I deploy my application to websphere I am having this linkage errors. A similar issue can be found here: LinkageError when calling webservice method but not sure what to do to fix it

Mainly it loaded from com/ibm/oti/vm/BootstrapClassLoader and com/ibm/ws/classloader/CompoundClassLoader with the shared class javax/xml/soap/SOAPFault

Caused by: java.lang.LinkageError: loading constraint violation: loader "com/ibm/oti/vm/BootstrapClassLoader@dda62209" previously initiated loading for a different type with name "javax/xml/soap/SOAPFault" defined by loader "com/ibm/ws/classloader/CompoundClassLoader@fdebcda2"
        at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
        at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:63)
        at javax.xml.ws.soap.SOAPFaultException.<init>(SOAPFaultException.java:78)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:160)
        at com.sun.proxy.$Proxy118.collectionsInquiryV2(Unknown Source)

What I have is jsp calling a webservice. From the message the only jars I saw is from axis.jar with contains the class javax/xml/soap/SOAPFault

does it mean I need to remove the SOAPFault.class from axis.jar? (it does not work tried and other webservice would fail if this was removed)

解决方案

Do you have a SOAP API jar in your application? The "loading constraint violation" LinkageError generally implies duplicate visibility to a class through two different class loaders. What I'm guessing is happening here based on the stack is that your application has the SOAP API but not the JAX-WS API. When that JAX-WS class references the SOAP class, that means that the classes in your app can "see" the SOAP API from two different loaders - directly, in the local class loader, and indirectly through the JAX-WS API.

Simplest answer is just to get rid of any SOAP API jar(s) in your app - you can just rely on the copy in the server, unless you have a really specific version need. Alternately, you could add a JAX-WS API jar to the application package, so the application loads its own copy of the API rather than pulling it from the server.

这篇关于LinkageError:加载违反约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆