jackson 链接错误:覆写方法javax/xml/stream/XMLInputFactory.createXMLEventReader时发生载入限制违规

rryofs0p  于 2022-11-08  发布在  Java
关注(0)|答案(1)|浏览(130)

我正在将一个托管在WebSphere 9上运行IBM JDK 8的应用程序从Spring 4.0.3升级到5.3.18。在此过程中,我将项目的Jackson、Woodstox和Stax 2依赖项更新到了它们的最新版本。应用程序会构建,但在启动时将XML字符串转换为JSON时,会出现以下错误:

java.lang.LinkageError: loading constraint violation when overriding method "javax/xml/stream/XMLInputFactory.createXMLEventReader(Ljavax/xml/transform/Source;)Ljavax/xml/stream/XMLEventReader;" during creation of class "com/ctc/wstx/stax/WstxInputFactory": loader "com/ibm/ws/classloader/CompoundClassLoader@c586bf67" of class "com/ctc/wstx/stax/WstxInputFactory" and loader "com/ibm/oti/vm/BootstrapClassLoader@8a89d546" of class "javax/xml/stream/XMLInputFactory" have different types for the method signature
at java.lang.ClassLoader.defineClassImpl(Native Method) ~[?:2.9 (11-06-2019)]
at java.lang.ClassLoader.defineClassInternal(ClassLoader.java:397) ~[?:2.9 (11-06-2019)]
at java.lang.ClassLoader.defineClass(ClassLoader.java:358) ~[?:2.9 (11-06-2019)]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154) ~[?:1.8.0]
at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:876) ~[com.ibm.ws.runtime.jar:WAS90.SERV1 [f5021945.01]]
at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:754) ~[com.ibm.ws.runtime.jar:WAS90.SERV1 [f5021945.01]]
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:622) ~[com.ibm.ws.runtime.jar:WAS90.SERV1 [f5021945.01]]
at java.lang.ClassLoader.loadClass(ClassLoader.java:871) ~[?:2.9 (11-06-2019)]
at java.lang.Class.forNameImpl(Native Method) ~[?:2.9 (11-06-2019)]
at java.lang.Class.forName(Class.java:403) ~[?:2.9 (11-06-2019)]
at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:381) ~[?:1.8.0]
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:415) ~[?:1.8.0]
at java.util.ServiceLoader$1.next(ServiceLoader.java:491) ~[?:1.8.0]
at javax.xml.stream.FactoryFinder.findServiceProvider(Unknown Source) ~[?:?]
at javax.xml.stream.FactoryFinder.find(Unknown Source) ~[?:?]
at javax.xml.stream.XMLInputFactory.newFactory(Unknown Source) ~[?:?]
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:115) ~[jackson-dataformat-xml-2.13.2.jar:2.13.2]
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:101) ~[jackson-dataformat-xml-2.13.2.jar:2.13.2]
at com.fasterxml.jackson.dataformat.xml.XmlFactory.<init>(XmlFactory.java:85) ~[jackson-dataformat-xml-2.13.2.jar:2.13.2]
at com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:127) ~[jackson-dataformat-xml-2.13.2.jar:2.13.2]

我不明白这个错误的原因。在升级的早期我遇到了不同的LinkageErrors,这些错误通过删除Jackson不再使用的依赖项(jsr173_api,stax-api和wstx-asl)得到了解决,但是我一直无法解决这个错误。

dfddblmv

dfddblmv1#

我遇到了同样的问题,并以以下方式解决了它,错误显示重复的“XMLInputFactory”类可能存在于应用程序包含的依赖项或服务器依赖项的不同依赖项中,或者同时存在于这两个依赖项中。
如果可能话,从应用程序中移除重复的依赖关系;如果不可能的话,至少使具有类“XMLInputFactory”的依赖关系的作用域与“provided”或“compile”相同。

相关问题