I'm getting this error
03:33:14,938 WARN [org.jboss.resteasy.core.ExceptionHandler] (default task-1) Failed executing PUT /individual/5a247ce9-0a73-4373-89ce-e4177f911259/activities/432e6e5b-4185-462f-b57e-9ec04bec3d58: org.jboss.resteasy.spi.ReaderException: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class java.time.Instant] from JSON String; no single-String constructor/factory method (through reference chain: com.lm.activity.DTOActivity["created"])
It's because Wildfly doesn't know how to handle an instant. By reading the error I could simply handle it in that class, but that seems silly. I'm using the following library and am shipping it and all of an updated jackson in my war
file, but that alone isn't doing it.
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.3.2</version>
</dependency>
I found this wiki
but my implementation is problematic, the class definition statement has an error
package com.lm.infrastructure;
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
@Provider
@Produces( MediaType.APPLICATION_JSON )
public class JacksonProducer implements ContextResolver<ObjectMapper> {
public JacksonProducer() throws Exception {
this.json = new ObjectMapper()
.findAndRegisterModules()
.configure( FAIL_ON_UNKNOWN_PROPERTIES, false );
}
@Override
public ObjectMapper getContext( Class<?> type ) {
return json;
}
private final ObjectMapper json;
}
I put this in my web.xml
(not to be confused with jboss-web.xml
)
<web-app ...
<context-param>
<param-name>resteasy.providers</param-name>
<param-value>com.lm.infrastructure.JacksonProducer</param-value>
</context-param>
</web-app>
I tried modifying modules/system/layers/base/com/fasterxml/jackson/jaxrs/jackson-jaxrs-json-provider/main/module.xml
which seems to be suggested here
<module xmlns="urn:jboss:module:1.1" name="com.fasterxml.jackson.jaxrs.jackson-jaxrs-json-provider">
<resources>
<resource-root path="jackson-jaxrs-json-provider-2.3.2.jar"/>
<resource-root path="jackson-jaxrs-base-2.3.2.jar"/>
<resource-root path="jackson-module-jaxb-annotations-2.3.2.jar"/>
<resource-root path="jackson-databind-2.3.2.jar"/>
<resource-root path="jackson-datatype-jsr310-2.3.2.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.ws.rs.api"/>
<module name="javax.xml.bind.api"/>
<module name="com.fasterxml.jackson.core.jackson-annotations"/>
<module name="com.fasterxml.jackson.core.jackson-core"/>
<module name="com.fasterxml.jackson.core.jackson-databind"/>
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310"/>
</dependencies>
</module>
My primary goal is to get jsr310 serializing and deserializing. What do I need to do to make this happen? but I suspect that the answer would apply to any additional datatype that doesn't ship with wildfly. (I think this issue is related )