6

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>

But it seems that JBoss uses the delivered module instead of the provided dependency.

ModuleClassLoader for Module "com.fasterxml.jackson.core.jackson-databind:main" from local module loader @134593bf (finder: local module finder @4bb4de6a (roots: ...\jboss-eap-7.0\modules,...\jboss-eap-7.0\modules\system\layers\base))

I have found a similar question JBoss 7 Classloader -- Exclude Module Implementation but it didn't help me.

What did I miss?

Community
  • 1
  • 1
CSchulz
  • 10,882
  • 11
  • 60
  • 114

2 Answers2

19

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>

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.

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>
Antares42
  • 1,406
  • 1
  • 15
  • 45
  • I did the same as suggested, but still I got error as `Caused by: org.jboss.modules.ModuleLoadError: com.fasterxml.jackson.datatype.jackson-datatype-jdk8` , I am using wildfly 14 and working with keycloak create an issue. Java 11 and spring 4.3.12. – minu Feb 25 '19 at 05:38
  • It resolves my problem, I was excluding from deployment , instead from sub-deployment. Thanks. – minu Feb 25 '19 at 09:13
  • hmmm still getting the `is not assignable to` errors mentioned above. I do include `jackson-datatype-jdk8` and `jackson-datatype-jsr310` explicitly in my gradle build script. Not sure if that makes this different. – Drew13 Nov 19 '19 at 20:14
  • yeah in my case i was deploying spring boot with spring jdbc and jpa enabled. this fixes my issues. – Nicholas DiPiazza Dec 22 '20 at 16:38
6

It looks like the jax-rs submodule from jboss eap 7 uses jackson. As soon as you skip this submodule, you will get rid of the jboss jackson version:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
    <deployment>
        <exclude-subsystems>
            <subsystem name="jaxrs"/>
        </exclude-subsystems>
    </deployment>
</jboss-deployment-structure>

(only makes sense if you don't use jaxrs ;-)

Dudelilama
  • 409
  • 4
  • 15
  • Well, we do. Just that we explicitly use Jackson as well. :-/ – Antares42 Sep 26 '17 at 20:59
  • I have a problem with the deserialization of Json, “prevented for security reasons” And J am trying to exclude the library responsible for that exception, Jackson-mapper-asl, is that also part of jaxrs? – Bionix1441 Dec 01 '20 at 03:20
  • 1
    I was facing issues after upgrading jboss from 6.2 to 7.3: https://stackoverflow.com/questions/68781412/different-response-when-application-deployed-in-jboss-6-2-vs-jboss-7-3 This answer has solved my issue. Thanks much. – dexterous-unwrapped Aug 16 '21 at 07:28