I am using WildFly 8.0.0 Final. The rest WebService implementation is RestEasy. According to the WildFly/Jboss documentation, I have added jboss-deployment-structure.xml to use Jackson2.2.* provider.
<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>
Right now, my problem is that all the java.util.Date variables are not serialize as ISO-8601 format. I have seen this post Wildfly using the Jackson provider instead of Jettison , but it's using jackson-provider-1.
Is there any configuration that can make all date variables be formatted as ISO-8601?
I don't want to add any outside dependencies. Only using WildFly provided is the best choice. I have add the below dependency into my pom.xml file. My code is at https://github.com/evil850209/javaee7-samples
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
I have done the something as this post (Wildfly using the Jackson provider instead of Jettison) mentioned. Now I got new error:
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ObjectMapper
at org.chris.demo.rest.JacksonConfig.<init>(JacksonConfig.java:18)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.7.0_25]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) [rt.jar:1.7.0_25]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.7.0_25]
at java.lang.reflect.Constructor.newInstance(Constructor.java:526) [rt.jar:1.7.0_25]
at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:148)
I have changed my jboss-deployment-structure.xml, and I put it under WEB-INF folder.
<?xml version="1.0" ?>
<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" />
<module name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider" />
</dependencies>
</deployment>
</jboss-deployment-structure>
My JacksonConfig class is like:
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonConfig implements ContextResolver<ObjectMapper> {
private final ObjectMapper objectMapper;
public JacksonConfig() {
objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
}
@Override
public ObjectMapper getContext(Class<?> type) {
return objectMapper;
}
}
It seems like the jboss-deployment-structure.xml is not import the jackson2 class to my WildFly server. Is there anyone how to resolve this issue?