EasterBunnyBugSmasher
EasterBunnyBugSmasher

Reputation: 1582

using Jackson annotations in Wildfly

I'm struggling to get Jackson Annotations to work in my project which is deployed in wildfly.

I already tried implementing a MessageBodyWriter but no success. My project looks like this: I have an ear with an ejb module which holds the annotated Pojos and I have a web module with the REST services. This is my current configuration / dependencies:

ejb-module pom.xml:

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

rest-module pom.xml:

no jackson dependencies.

ear-project pom.xml:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>2.2.3</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.2.3</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.2.3</version>
</dependency>
<dependency>
    <groupId>org.jboss.resteasy</groupId>
    <artifactId>resteasy-jackson2-provider</artifactId>
    <version>3.0.6.Final</version>
</dependency>

ear-project /META-INF/jboss-deployment-structure.xml:

<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> 

but the jackson annotations are ignored. What am I missing? or did I do too much?

Upvotes: 3

Views: 5036

Answers (1)

James R. Perkins
James R. Perkins

Reputation: 17780

The RESTEasy and Jackson dependencies should be marked as <scope>provided</scope>.

Also if you're only using JAX-RS and Jackson in your WAR, just move jboss-deployment-structure.xml to your WAR/WEB-INF directory. If you don't want to move it you might need to add a <sub-deployment/>.

<jboss-deployment-structure>
    <sub-deployment name="rest-module.war">
        <exclusions>
           <module name="org.jboss.resteasy.resteasy-jackson-provider"/>
        </exclusions>
        <dependencies>
            <module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
        </dependencies>
    </sub-deployment>
</jboss-deployment-structure> 

Upvotes: 3

Related Questions