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

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

问题描述

我在 websphere 应用程序服务器 (8.5.5.14) 中遇到 LinkageError.在这里发现了一个类似的问题LinkageError

Caused by: java.lang.LinkageError: 在解析方法javax/xml/soap/SOAPElement.getElementQName()Ljavax/xml/namespace/QName;"时加载约束冲突:加载器com/ibm/ws/classloader/CompoundClassLoader@19d4f90e"org/springframework/ws/soap/saaj/SaajSoapElement"类的和加载程序com/ibm/oti/vm/BootstrapClassLoader@ca532309"类javax/xml/soap/SOAPElement"方法签名有不同的类型

解决方案

问题的原因是在您的应用程序中包含了一个包含 javax/xml/namespace/QName 的 XML API jar,并且该应用程序被配置为使用 parent-最后一个类加载.发生这种情况时,您会得到以下链接模式:

  1. 应用程序类引用 javax/xml/soap/SOAPElement - 这个类是从 JDK 加载的
  2. SOAPElement 引用 javax/xml/namespace/QName - 它使用自己的类加载器加载它,因此它也可以在 JDK 中找到
  3. 应用程序类引用 org/springframework/ws/soap/saaj/SaajSoapElement - 这个类是从应用程序加载的
  4. SaajSoapElement 同时引用 SOAPElement 和 QName - SOAPElement 是从 JDK 加载的(和以前一样),但 QName 是从应用程序加载的,因为 parent-last 类加载器委托要求类加载器在委托给父类之前在本地搜索
  5. SaajSoapElement 现在可以看到"QName 和 Java 的两个副本都会抛出 LinkageError,因为这违反了加载约束

您可以通过从您的应用程序中删除包含 QName 类的 XML jar(该 API 包含在服务器的 JDK 中)来解决这个问题,方法是将 SOAP API 添加到应用程序中(因此应用程序看到"了来自应用程序的两个类).相同的位置),或者通过将类加载切换为父级优先.父最后一个类加载通常容易受到此类问题的影响,因为它允许在类加载器之间进行比默认设置下通常可能更多的重复加载.如果您对自己的 XML API 版本没有非常明确的需求(XML API 已经包含在 Java SE 中很长时间了),我强烈建议您删除 jar 或切换到 parent-first.

I am facing LinkageError in websphere application server(8.5.5.14). A similar issue found here LinkageError

Caused by: java.lang.LinkageError: loading constraint violation when resolving method "javax/xml/soap/SOAPElement.getElementQName()Ljavax/xml/namespace/QName;" : loader "com/ibm/ws/classloader/CompoundClassLoader@19d4f90e" of class "org/springframework/ws/soap/saaj/SaajSoapElement" and loader "com/ibm/oti/vm/BootstrapClassLoader@ca532309" of class "javax/xml/soap/SOAPElement" have different types for the method signature

解决方案

The cause of the issue is the inclusion of an XML API jar containing javax/xml/namespace/QName in your application, and that application being configured to use parent-last class loading. When that happens, you get the following linkage pattern:

  1. Application class references javax/xml/soap/SOAPElement - this class is loaded from the JDK
  2. SOAPElement references javax/xml/namespace/QName - it loads that using its own class loader, so it's also found in the JDK
  3. Application class references org/springframework/ws/soap/saaj/SaajSoapElement - this class is loaded from the application
  4. SaajSoapElement references both SOAPElement and QName - SOAPElement is loaded from the JDK (as before), but QName is loaded from the application, because parent-last class loader delegation requires that the class loader search locally before delegating to parents
  5. SaajSoapElement now can "see" both copies of QName, and Java throws a LinkageError, because that violates loading constraints

You can solve this by removing the XML jar containing the QName class from your application (the API is included in the server's JDK), by adding the SOAP API to the application (so the application "sees" both classes from the same location), or by switching your class loading to parent-first. Parent-last class loading is generally vulnerable to issues like this, because it allows for more duplicate loading between class loaders than is typically possible under default settings. If you don't have a very explicit need for your own XML API version (XML APIs have been included in Java SE for a very long time), I'd strongly recommend either removing the jar or switching to parent-first.

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

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