-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
Customer reported an error
Caused by: java.lang.ExceptionInInitializerError: Exception java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: com.fasterxml.jackson.datatype.jsr310.JavaTimeModule not a subtype [in thread "ServerService Thread Pool -- 74"]
when deploy a Hibernate application which has Jackson libraries as dependencies.
Caused by: java.lang.ExceptionInInitializerError: Exception java.util.ServiceConfigurationError: com.fasterxml.jackson.databind.Module: com.fasterxml.jackson.datatype.jsr310.JavaTimeModule not a subtype [in thread "ServerService Thread Pool -- 74"]
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:593)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1244)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
at com.fasterxml.jackson.core.jackson-databind@2.18.4.redhat-00002//com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:1160)
at com.fasterxml.jackson.core.jackson-databind@2.18.4.redhat-00002//com.fasterxml.jackson.databind.ObjectMapper.findModules(ObjectMapper.java:1144)
at com.fasterxml.jackson.core.jackson-databind@2.18.4.redhat-00002//com.fasterxml.jackson.databind.ObjectMapper.findAndRegisterModules(ObjectMapper.java:1194)
at org.hibernate@6.6.18.Final-redhat-00001//org.hibernate.type.format.jackson.JacksonJsonFormatMapper.<init>(JacksonJsonFormatMapper.java:27)
at org.hibernate@6.6.18.Final-redhat-00001//org.hibernate.type.format.jackson.JacksonIntegration.<clinit>(JacksonIntegration.java:18)
Inside class initialization (the <clinit> call in the stack trace) it is invalid to have ANY dependencies on being called from a specific context. But that stack trace does.
The ObjectMapper.findAndRegisterModules call it's making depends on the thread's context classloader, which Hibernate does not set and therefore is dependent on what context the class gets loaded in.
JacksonJsonFormatMapper must either set the TCCL to a static value (probably its own classloader)
before making that call, or use the version of the call that uses a specific classloader:
The current wrong call (unless explicitly setting the TCCL):
this(new ObjectMapper().findAndRegisterModules());
The correct call would be:
this(new ObjectMapper().registerModules(ObjectMapper.findModules(this.class.getClassLoader())));
That call is new in EAP 8.1. In 8.0 JacksonJasonFormatMapper did not call the findAndRegisterModules method causing the issue:
this(new ObjectMapper());
The bug was introduced in Hibernate 6.3.0 with the commit:
commit 33258a9c494274d274cc3009cafe0491c814022b Author: Christian Beikov <christian.beikov@gmail.com> Date: Wed Aug 16 20:03:32 2023 +0200 HHH-17098 Auto-discover ObjectMapper modules for JacksonJsonFormatMapper
- is incorporated by
-
JBEAP-31250 [GSS](8.1.z) Upgrade hibernate ORM from 6.6.31.Final-redhat-00001 to 6.6.34 or later
-
- New
-