[英]How can I force a JBoss deployment to use a specific version of a dependency instead of installed modules?
When deploying an *.ear to JBoss, it always uses the wrong version of com.fasterxml.jackson.core
. 将* .ear部署到JBoss时,它始终使用
com.fasterxml.jackson.core
的错误版本。
My code is using featuers of com.fasterxml.jackson.core version 2.9.0 and compiles fine, but when calling the code in JBoss, I got java.lang.NoSuchFieldError
. 我的代码使用com.fasterxml.jackson.core版本2.9.0的功能,并且可以正常编译,但是在JBoss中调用代码时,出现了
java.lang.NoSuchFieldError
。
To me it seems, that JBoss classloader uses the already installed jackson module version 2.5.0. 在我看来,JBoss类加载器使用已安装的杰克逊模块版本2.5.0。
How can I have JBoss classloader to use version 2.9.0 for my deployment? 如何让JBoss类加载器将2.9.0版用于部署?
Situation 情况
I am developing a plugin for Keycloak , which I test locally by deploying it via the Keycloak Docker Image Version 3.2.1. 我正在开发Keycloak插件,可以通过Keycloak Docker映像版本3.2.1对其进行本地部署,以对其进行本地测试。
The ear is deployed by copying it to $JBOSS_HOME/standalone/deployments before launching the image, and the plugin works fine until I use functions from jackson 2.9. 通过在启动映像之前将其复制到$ JBOSS_HOME / standalone / deployments来部署耳朵,并且该插件可以正常工作,直到我使用杰克逊2.9的功能为止。
What I have tried so far: 到目前为止我尝试过的是:
I pinned the version via pom.xml: 我通过pom.xml固定了版本:
<dependencyManagement>
<dependencies>
<dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
I excluded the jackson-modules in my jboss-deployment-structure.xml: 我在jboss-deployment-structure.xml中排除了杰克逊模块:
<deployment>
<dependencies>
<module name="org.keycloak.keycloak-core" export="true" />
<module name="org.keycloak.keycloak-server-spi" export="true" />
<module name="org.keycloak.keycloak-server-spi-private" export="true" />
<module name="org.keycloak.keycloak-services" export="true" />
<module name="org.bouncycastle" export="true" />
<module name="com.google.guava" export="true" />
<module name="org.jboss.logging" export="true" />
</dependencies>
<exclusions>
<module name="com.fasterxml.jackson.core.jackson-core" />
<module name="com.fasterxml.jackson.core.jackson-databind" />
<module name="com.fasterxml.jackson.core.jackson-annotations" />
</exclusions>
</deployment>
I checked the dependencies tree: 我检查了依赖关系树:
mvn dependency:tree | grep jackson
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.9.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] \- com.github.kittinunf.fuel:fuel-jackson:jar:1.12.0:runtime
[INFO] +- com.fasterxml.jackson.module:jackson-module-kotlin:jar:2.9.0:runtime
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.9.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-databind:jar:2.9.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] \- com.github.kittinunf.fuel:fuel-jackson:jar:1.12.0:runtime
[INFO] +- com.fasterxml.jackson.module:jackson-module-kotlin:jar:2.9.0:runtime
The jackson 2.5 library is pre-installed since Keycloak depends on it: 由于Keycloak依赖于它,因此已预先安装了jackson 2.5库:
find ${JBOSS_HOME}/modules | grep jackson-core
/opt/jboss/keycloak/modules/system/layers/base/com/fasterxml/jackson/core/jackson-core
/opt/jboss/keycloak/modules/system/layers/base/com/fasterxml/jackson/core/jackson-core/main
/opt/jboss/keycloak/modules/system/layers/base/com/fasterxml/jackson/core/jackson-core/main/module.xml
/opt/jboss/keycloak/modules/system/layers/base/com/fasterxml/jackson/core/jackson-core/main/jackson-core-2.5.4.jar
When I unzip my *.ear package, I find the jackson-jars with correct version in libs/
( META-INF/MANIFEST.MF
says Bundle-Version: 2.9.0
: 解压缩* .ear软件包时,我在
libs/
找到具有正确版本的jackson-jars( META-INF/MANIFEST.MF
表示Bundle-Version: 2.9.0
:
ls lib | grep jackson
jackson-annotations.jar
jackson-core.jar
jackson-databind.jar
Can anyone explain to me, if and how I can make JBoss use the correct version of jackson? 任何人都可以向我解释,是否以及如何使JBoss使用正确版本的jackson?
Thank you! 谢谢!
Try adding the following modules to <exclusions>
. 尝试将以下模块添加到
<exclusions>
。
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="com.fasterxml.jackson.module.jackson-module-jaxb-annotations" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-base" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.