{ "jboss.depl-6ren">
gpt4 book ai didi

java - 类型 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module'(当前帧,堆栈 [2])不可分配给 'com/fasterxml/jackson/databind/Module'

转载 作者:行者123 更新时间:2023-12-03 03:45:32 28 4
gpt4 key购买 nike

我将 jackson 库从 2.5.4 升级到 2.10.1,如下所示,我收到以下错误:

"WFLYCTL0080: Failed services" => {
"jboss.deployment.subunit.\"m2m-rt.ear\".\"app.jar\".POST_MODULE" => "org.jboss.msc.service.StartException in service jboss.deployment.subunit.\"app.ear\".\"app.jar\".POST_MODULE: WFLYSRV0153: Failed to process phase POST_MODULE of subdeployment \"app.jar\" of deployment \"app.ear\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class Class with ClassLoader ModuleClassLoader for Module \"deployment.app.jar:main\" from Service Module Loader
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
Location:
Class.<init>()V @19: invokevirtual
Reason:
Type 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module' (current frame, stack[2]) is not assignable to 'com/fasterxml/jackson/databind/Module'

通过我自己的研究,我发现在我的 jboss-deployment-structure.xml 中排除 jackson 库应该相当简单:
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<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>
<dependencies>
<module name="org.picketbox"/>
<module name="org.wildfly.clustering.singleton"/>
<module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import"/>
<module name="org.apache.cxf.impl" export="true">
<imports>
<include path="META-INF" />
<include path="META-INF/cxf" />
<include path="META-INF/services" />
</imports>
</module>
</dependencies>
</deployment>
<sub-deployment name="other.jar">
<dependencies>
<module name="org.infinispan" slot="5.2"/>
</dependencies>
</sub-deployment>
</jboss-deployment-structure>

我还尝试将其包含在我的 jboss 部署结构中,而不是在根级别进行排除:
<sub-deployment name="firstJar.jar">
<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>
</sub-deployment>

这是我在我的 gradle 构建脚本中定义我的 jackson 库的方式。这些库是一个 jar 的一部分,它与其他几个 jar 一起部署,并引发了一场 war 。其他四个 jar 模块依赖于包含 jackson 库的 jar

我的第一个 jar 的一部分:
compile 'com.fasterxml.jackson.core:jackson-core:2.10.1'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1'
compile 'com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.1'

另一个依赖于上述 jar 的 gradle 构建脚本:
dependencies {
compile project(':components:firstJar')
}

使用 JBoss EAP 7.0.5

当我运行 gradle 依赖项扫描时,我注意到的一件事是使用 2.5.4 版本的 jackson 库,我的扫描看起来像这样:
    +--- com.fasterxml.jackson.core:jackson-core:2.5.4
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.5.4
| | +--- com.fasterxml.jackson.core:jackson-core:2.5.4
| | \--- com.fasterxml.jackson.core:jackson-databind:2.5.4
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.5.0
| | \--- com.fasterxml.jackson.core:jackson-core:2.5.4
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.5.4
| | +--- com.fasterxml.jackson.core:jackson-core:2.5.4
| | \--- com.fasterxml.jackson.core:jackson-databind:2.5.4 (*)
| \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.5.4
| +--- com.fasterxml.jackson.core:jackson-core:2.5.4
| \--- com.fasterxml.jackson.core:jackson-databind:2.5.4 (*)

当我为 2.10.1 运行它时,它看起来像这样:
|    +--- com.fasterxml.jackson.core:jackson-core:2.5.4 -> 2.10.1
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1
| | +--- com.fasterxml.jackson.core:jackson-core:2.10.1
| | \--- com.fasterxml.jackson.core:jackson-databind:2.10.1
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.1
| | \--- com.fasterxml.jackson.core:jackson-core:2.10.1
| +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1
| | +--- com.fasterxml.jackson.core:jackson-annotations:2.10.1
| | +--- com.fasterxml.jackson.core:jackson-core:2.10.1
| | \--- com.fasterxml.jackson.core:jackson-databind:2.10.1 (*)
| \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.1
| +--- com.fasterxml.jackson.core:jackson-core:2.10.1
| \--- com.fasterxml.jackson.core:jackson-databind:2.10.1 (*)

我注意到有一个额外的 jackson-annotations 2.10.1 的依赖项。所以我尝试添加 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'对于 jackson-datatype-jsr310我的 gradle 脚本中的库,它确实将其从依赖项扫描中删除。但我仍然有同样的错误。我也想知道为什么在 2.10.1 的依赖项扫描的第一行中,它说 2.5.4 -> 2.10.1 .

最佳答案

我最终需要排除 jacksonresteasy多个模块 (jar) 中的库以及我的 jboss-deployment-structure.xml 中的根级别的库.我指定排除库的模块使用导入库的模块(即在我的问题中我声明 A gradle build script of another jar that depends on the one above: 的位置)。

<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<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>
<dependencies>
<module name="org.picketbox"/>
<module name="org.wildfly.clustering.singleton"/>
<module name="org.jboss.ws.cxf.jbossws-cxf-client" services="import"/>
<module name="org.apache.cxf.impl" export="true">
<imports>
<include path="META-INF" />
<include path="META-INF/cxf" />
<include path="META-INF/services" />
</imports>
</module>
</dependencies>
</deployment>
<sub-deployment name="moduleThatDependsOnFirst.jar">
<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>
</sub-deployment>
<sub-deployment name="anotherModuleThatDependsOnFirst.jar">
<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>
</sub-deployment>
</jboss-deployment-structure>

我不明白的一件事是为什么我不需要为使用导入库的模块的其他 jar 排除库。
因此,我对其他有此问题的人的建议是尝试使用您从哪些 jar 中排除库以使其正常工作。

关于java - 类型 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module'(当前帧,堆栈 [2])不可分配给 'com/fasterxml/jackson/databind/Module',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59032599/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com