Wildfly 22 to 23: Getting "Java 8 date/time type `java.time.LocalDate` not supported by default"

3,264 views
Skip to first unread message

jpu...@noverant.com

unread,
Apr 23, 2021, 12:31:08 PM4/23/21
to WildFly

As the subject states, when moving from Wildfly 22 to Wildfly 23, my application is all of a sudden throwing this error when trying to serialize Java 8 LocalDate and LocalDateTime objects.

I added these lines to my `jboss-deployment-structure.xml` file, but it didn't seem to help:

<module name="com.fasterxml.jackson.datatype.jackson-datatype-jsr310" services="import" />
<module name="com.fasterxml.jackson.datatype.jackson-datatype-jdk8" services="import" />


Am I missing something? Did something change around RESTEasy/Jackson in Wildfly 23?

Regards,
Jonathan

James Perkins

unread,
Apr 23, 2021, 4:32:34 PM4/23/21
to WildFly
Can you share your jboss-deployment-structure.xml? I can't seem to reproduce this.

jpu...@noverant.com

unread,
Apr 23, 2021, 5:03:10 PM4/23/21
to WildFly
Here you go. Let me know if any other info would help.
jboss-deployment-structure.xml

James Perkins

unread,
Apr 23, 2021, 5:05:11 PM4/23/21
to WildFly
Sorry, I forgot to set Jackson as the default provider. This does look like a regression in WildFly. I've filed an issue for this https://issues.redhat.com/browse/WFLY-14737.

James Perkins

unread,
Apr 26, 2021, 8:05:38 PM4/26/21
to WildFly
To follow up on this it appears we're missing some documentation. To get this to work you need to add a provider which explicitly loads the JSR 310 module. In your deployment you can just add something 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.json.JsonMapper;

@Provider
@Produces(MediaType.APPLICATION_JSON)
public class JacksonDatatypeJacksonProducer implements ContextResolver<ObjectMapper> {

    private final ObjectMapper json;

    public JacksonDatatypeJacksonProducer() throws Exception {
        this.json = JsonMapper.builder()
                .findAndAddModules()
                .build();
    }

    @Override
    public ObjectMapper getContext(Class<?> objectType) {
        return json;
    }
}

That should activate the JSR 310 serializer. You also don't need to include the dependencies in the jboss-deployment-structure.xml.

Praveen 23

unread,
Feb 3, 2022, 1:36:37 AM2/3/22
to WildFly
Hi,

Where I need to add this class  JacksonDatatypeJacksonProducer in My project

Can you please share the path 

Reply all
Reply to author
Forward
0 new messages