从 JBoss 7 EAP 中排除提供的 jackson 版本 [英] Exclude provided jackson version from JBoss 7 EAP
问题描述
我正在尝试使用 JBoss 7 EAP 提供的较新版本的 Jackson.为了解决我的问题,我创建了一个 jboss-deployment-structure.xml 文件,该文件包含在我的战争部署中.
I am trying to use a newer version of Jackson as JBoss 7 EAP delivers. To solve my issue I have created a jboss-deployment-structure.xml file which is contained in my war deployment.
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<!--<module name="com.fasterxml.jackson.core.jackson-core" slot="main" />-->
<!--<module name="com.fasterxml.jackson.core.jackson-annotations" slot="main" />-->
<module name="com.fasterxml.jackson.core.jackson-databind" slot="main" />
</exclusions>
</deployment>
</jboss-deployment-structure>
但似乎 JBoss 使用的是交付的模块而不是提供的依赖项.
But it seems that JBoss uses the delivered module instead of the provided dependency.
模块类加载器来自本地模块的com.fasterxml.jackson.core.jackson-databind:main"loader @134593bf(查找器:本地模块查找器@4bb4de6a(根:...jboss-eap-7.0modules,...jboss-eap-7.0modulessystemlayersase))
ModuleClassLoader for Module "com.fasterxml.jackson.core.jackson-databind:main" from local module loader @134593bf (finder: local module finder @4bb4de6a (roots: ...jboss-eap-7.0modules,...jboss-eap-7.0modulessystemlayersase))
我发现了一个类似的问题 JBoss 7 类加载器 -- 排除模块实现,但它对我没有帮助.
I have found a similar question JBoss 7 Classloader -- Exclude Module Implementation but it didn't help me.
我错过了什么?
推荐答案
我遇到了与 Jackson 完全相同的问题,我使用这个 jboss-deployment-structure.xml<在我的 EAP 7 中使用了它/代码>:
I ran into the exact same problem with Jackson, and I got it to work in my EAP 7 using this jboss-deployment-structure.xml
:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-annotations" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>
看起来只要任何其他模块在各自的module.xml
中将jackson列为它们的依赖项,它就不会被排除在外,EAP可以甚至不要为此发出警告.
It appears like as long as any other modules list jackson as their dependency in their respective module.xml
, it just simply doesn't get excluded, and EAP can't be arsed to even throw a warning about it.
编辑 2018-02-19: 当从 EAP 7.0.0 升级到 7.1.0 时,由于更新的 Jackson jars,事情再次出现问题.
Edit 2018-02-19: When upgrading from EAP 7.0.0 to 7.1.0, things broke again, owing to updated Jackson jars.
这是堆栈跟踪的关键部分:
This is the crucial part of the stacktrace:
Caused by: javax.ejb.EJBException: WFLYEJB0442: Unexpected Error
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:185)
[...]
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) [wildfly-ee-7.1.0.GA-redhat-11.jar:7.1.0.GA-redhat-11]
... 11 more
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
[...]()Lcom/fasterxml/jackson/databind/ObjectMapper; @89: invokevirtual
Reason:
Type 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module' (current frame, stack[1]) is not assignable to 'com/fasterxml/jackson/databind/Module'
所以我们也排除了这些:
So we exclude those as well:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-annotations" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jdk8" />
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
</exclusions>
</deployment>
</jboss-deployment-structure>
这篇关于从 JBoss 7 EAP 中排除提供的 jackson 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!