类型 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module'(当前帧,堆栈 [2])不可分配给 'com/fasterxml/jackson/databind/Module'
Type 'com/fasterxml/jackson/datatype/jdk8/Jdk8Module' (current frame, stack[2]) is not assignable to 'com/fasterxml/jackson/databind/Module'
我将我的 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 与其他一些 jar 和一个 war 一起部署到耳朵中。其他四个 jar 模块依赖于包含 jackson 库的 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'
一个 gradle 依赖于上面那个的另一个 jar 的构建脚本:
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 (*)
我注意到 2.10.1 有一个额外的 jackson-annotations
依赖项。所以我尝试在我的 gradle 脚本中为 jackson-datatype-jsr310
库添加 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
,这确实将它从依赖项扫描中删除了。但我仍然有同样的错误。我还想知道为什么在 2.10.1 的依赖项扫描的第一行显示 2.5.4 -> 2.10.1
。
我最终需要排除多个模块(罐子)中的 jackson
和 resteasy
库以及 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 从中排除库,以便使其正常工作。
我将我的 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 与其他一些 jar 和一个 war 一起部署到耳朵中。其他四个 jar 模块依赖于包含 jackson 库的 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'
一个 gradle 依赖于上面那个的另一个 jar 的构建脚本:
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 (*)
我注意到 2.10.1 有一个额外的 jackson-annotations
依赖项。所以我尝试在我的 gradle 脚本中为 jackson-datatype-jsr310
库添加 exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
,这确实将它从依赖项扫描中删除了。但我仍然有同样的错误。我还想知道为什么在 2.10.1 的依赖项扫描的第一行显示 2.5.4 -> 2.10.1
。
我最终需要排除多个模块(罐子)中的 jackson
和 resteasy
库以及 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 从中排除库,以便使其正常工作。