简体   繁体   English

如何强制JBoss部署使用特定版本的依赖性而不是已安装的模块?

[英]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.

相关问题 我可以强制maven依赖项A使用特定版本的依赖项B,同时使用其他版本的依赖项B吗? - Can I force a maven dependency A to use a specific version of a dependency B, whilst using a different version of dependency B along-side it? 在JBoss应用程序服务器中,如何确保部署中的所有模块对jar库使用相同的Classloader? - In JBoss application server, how do I make sure that all modules in a deployment use the same Classloader for a jar library? 从我的耳朵项目开始,如何使用Apache CXF 3.X和WSS4J 2.X,而不使用JBoss 6.3.0 EAP模块中安装的CXF和WSS4J(旧)? - How can I use Apache CXF 3.X and WSS4J 2.X as of my ear project and not CXF and WSS4J (older) that is installed in the modules of JBoss 6.3.0 EAP? Maven 下载特定版本,如何强制下载其他版本? - Maven downloading a specific version, how can I force to download an other? 可以/我如何强制JBoss和Eclipse只使用一个核心? - Can I / How can I force JBoss & Eclipse to use only one core? 如何强制依赖项包含具有特定版本号的工件 - How to force the dependency to include an artifact with a specific version number 如何强制Maven将版本号保留在依赖文件名之外? - How can I force maven to leave the version number out of dependency file names? 如何强制 java 应用程序使用 maven 依赖项的本地版本? - How to force a java app to use a local version of a maven dependency? 我可以在JBoss 5上使用JBoss MQ吗? 如果是这样,怎么样? - Can I use JBoss MQ on JBoss 5? If so, how? 如何在我的`gradle.build`中强制使用特定版本的jar? - How can I force specific jar with version from in my `gradle.build`?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM