How can I add jackson datatype jsr310 to my keycloak extension

I’m developing an extension to keycloak to add some capabilities and extendind the jpa domain. So far so good, I’m strugling with my custom rest-api. Some of my objects uses LocalDateTime object and it is causing an error when jackson tryies to serialize the representation object.

According to the stack trace, to fix that I need to just add an jsr310 jackson module in the ObjectMapper instance, but I’ve not found any clue to where configure this inside my extension.

 Uncaught server error: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: br.com.becomex.beconnect.spi.company.CompanyModel["created"])

Searching in the keycloack source code I found the org.keycloak.services.util.ObjectMapperResolver and I guess I could just create another one to replace this, but I do not want to mess with keycloak default objects.

Can someone help me to add and register the jsr310 module on keycloak 20 extension?

Hi, I have the same issue. Could you resolve this problem?

I didn’t solve this. Despite the interface I have found, there is no way to intercept the registration step because it is private and occurs in the very beginning bootstrap.

After spend too much time I just give up to use new DateTime objects and replace then to old fashion timestamps.