I have an application that has webservices built with Jersey and Jackson as JSON provider, all this in a Tomcat application server.
I need to make this application working on Wildfly 10 and everything is working fine, beside the webservice response that is not taking in consideration the Jackson annotations. From what I read Wildfly was using Jettison as default and in the newer version Jackson2 is used.
The preferred solution would be to make RestEasy (from Wildfly 10) to use Jackson and for this I tried to exclude Jackson2 and Jettison and make a dependency to Jackson in (META-INF\jboss-deployment-structure.xml), as below:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson2-provider"/>
<module name="org.jboss.resteasy.resteasy-jettison-provider"/>
</exclusions>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson-provider" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Apparently this is not enough, since is behaving as before. What else should I try?
UPDATE:
Since my application should work the same on both Tomcat (using Jersey) and Wildfly (using RestEasy), I cannot rely on using jackson from resteasy inside my application, hence I'm importing org.codehaus.jackson
.
So, I register my application like this:
import javax.ws.rs.core.Application;
public class RestApplication extends Application
{
@Override
public Set<Class<?>> getClasses() {
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(RestObjectMapperProvider.class);
classes.add(GeneratedService.class);
return classes;
}
}
And rest object mapper provider:
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.ObjectMapper;
@Provider
public class RestObjectMapperProvider implements ContextResolver<ObjectMapper>
{
private final ObjectMapper objectMapper;
public RestObjectMapperProvider()
{
this.objectMapper = new ObjectMapper();
this.objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
}
@Override
public ObjectMapper getContext(Class<?> type)
{
return this.objectMapper;
}
}
I'm building my app with Gradle and below is the Jackson dependency:
compile group: 'org.codehaus.jackson', name: 'jackson-jaxrs', version: '1.9.+'
Since under Tomcat (Jersey) the annotation are considered, my guess would be that in Wildfly my exclusions are not considered. Is there any way to check which JSON Provider was considered, beside checking the response?