7

I'm trying to configure jboss wildfly 8 to use Jackson for JSON. So I added

<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson-provider</artifactId>
    <version>3.0.6.Final</version>
    <type>jar</type>
</dependency>

to my ear project. But on deploying I get following error:

Caused by: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.jboss.resteasy.plugins.providers.jackson.ResteasyJacksonProvider$Proxy$_$$WeldClientProxy.disable(Lorg/codehaus/jackson/map/Des erializationConfig$Feature;Z)Lorg/codehaus/jackson/jaxrs/JacksonJsonProvider;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/jboss/resteasy/plugins/providers/jackson/ResteasyJacksonPr ovider$Proxy$$$WeldClientProxy, and its superclass loader (instance of org/jboss/modules/ModuleClassLoader), have different Class objects for the type sy.plugins.providers.jackson.ResteasyJacksonProvider$Proxy$$$_WeldClientProx y.disable(Lorg/codehaus/jackson/map/DeserializationConfig$Feature;Z)Lorg/codehaus/jackson/jaxrs/JacksonJsonProvider; used in the signature

Is version 3.0.6 not compatible with Wildfly? how do I know which version works? I also tried with 2.3.7 and 1.1 but always the same error.

EDIT:

I have a ejb module with pojos. Here I have the dependency:

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.2.3</version>
        <scope>provided</scope>
        <type>jar</type>
    </dependency>

so that looks very much like jackson 2 to me.

and in my ear, I have following dependency:

<dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jackson-provider</artifactId>
        <version>3.0.6.Final</version>
        <type>jar</type>
        <scope>provided</scope>
</dependency>

do I need resteasy-jackson2-provider now? Do I need the jboss-deployment-structure.xml now?

EasterBunnyBugSmasher
  • 1,507
  • 2
  • 15
  • 34

2 Answers2

7

WildFly 8 already includes Jackson. Mark the dependency with <scope>provided</scope>. You then need to add a jboss-deployment-structure.xml to your deployment with the following per the documentation.

<jboss-deployment-structure>
    <deployment>
        <exclusions>
           <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
        </exclusions>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure> 
James R. Perkins
  • 16,800
  • 44
  • 60
  • well, the error is gone. But there is no Jackson functionality. I'm using Jackson annotations and they do nothing. This is my current setup: I have an ear with a few artifacts like my REST war and an ejb jar with the annotated Objects. In the EJB module, I have a dependency to the jackson-annotations (provided). In my REST war, I included the jboss-deployment-structure.xml in the WEB-INF folder. To be sure, I also included the jboss-deployment-structure.xml in my ear WEB-INF folder (which one is right???). And in my ear, I have the dependency to resteasy-jackson-provider (provided). – EasterBunnyBugSmasher Mar 05 '14 at 21:12
  • do I also need a dependency in my war project? And is it correct that I have a dependency to resteasy-jackson and not jackson2 ? – EasterBunnyBugSmasher Mar 05 '14 at 21:18
  • Sorry I assumed Jackson 2 for some reason. If you want to use Jackson 1 then all you need to do is use the `provided` for your dependencies. The `jboss-deployment-stucture.xml` isn't needed for Jackson 1. – James R. Perkins Mar 05 '14 at 23:04
  • well, this is my dependency in my ejb module: com.fasterxml.jackson.core jackson-annotations 2.2.3 provided jar – EasterBunnyBugSmasher Mar 05 '14 at 23:19
  • I hate those comments. I'll just type an answer that is not an answer... /sigh – EasterBunnyBugSmasher Mar 05 '14 at 23:20
  • I edited the original question. I also tried if I could use jackson 1 annotations, but that doesn't seem to exist. So I guess I need jackson 2. – EasterBunnyBugSmasher Mar 05 '14 at 23:27
  • and where do I need to put the jboss-deployment-structure.xml file? Into the ear? or into the war? – EasterBunnyBugSmasher Mar 05 '14 at 23:28
  • Ah okay. For an EAR or a JAR it needs to go in the `META-INF` directory of the EAR. For a WAR it needs to be in the `WEB-INF` directory. – James R. Perkins Mar 05 '14 at 23:31
  • ok, now I have the jboss-deployment-structure.xml in my ear META-INF, I have the dependency to resteasy-jackson-provider 3.0.6 in my ear (tried with provided and without). But not working. I notice that resteasy-jackson-provider 3.0.6 seems to have dependencies on jackson 1.9.2 ... and that is without annotations. So no wonder I can't use annotations. I'm confused now. Isn't 3.0.6 the newest version of resteasy? – EasterBunnyBugSmasher Mar 06 '14 at 00:05
  • You can use RESTEasy with Jackson 2.2.x. That's where the inclusion for Jackson2 is needed in the jboss-deployment-structure.xml comes into play. If it's not working, then maybe something is configured wrong. Read over https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly and specifically the stuff around how the jboss-deployment-structure.xml works. – James R. Perkins Mar 06 '14 at 18:24
1

It worked for me when I imported <module name = "com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />, because <module name = "org.jboss.resteasy.resteasy-jackson2-provider" services = "Import" /> does not export it

<jboss-deployment-structure>
      <sub-deployment name="erp-integrator.jar">
        <exclusions>
           <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
        </exclusions>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import" />
            <module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
        </dependencies>
    </sub-deployment>
</jboss-deployment-structure>