Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-31316

[GSS](8.1.z) HHH-19887 - ServiceConfigurationError caused by Hibernate with Jackson dependencies

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • 8.1 Update 2
    • None
    • Hibernate
    • None
    • False
    • False
    • Hide

      Would be not to package Jackson API jars in an application that uses EAP's Hibernate.

      Show
      Would be not to package Jackson API jars in an application that uses EAP's Hibernate.
    • Hide

      1. Extract Reproducer.zip to any location
      2. Build the project with Reproducer $ gradle|gradlew clean build
      3. Start standard EAP 8.1.0 using standalone.bat
      4. Deploy Reproducer\ear\build\libs\reproducer-eap8.ear
      5. The deployment will fail with WFLYEJB0442: Unexpected Error
      6. You will find the following in the log file

      ERROR [org.jboss.as.server] (management-handler-thread - 5) WFLYSRV0021: Deploy of deployment "reproducer-eap8.ear" was rolled back with the following failure message:
      {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"reproducer-eap8.ear\".\"ejb.jar\".component.StartupBean.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
          Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
          Caused by: jakarta.ejb.EJBException: WFLYEJB0442: Unexpected Error
          Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.type.format.jackson.JacksonIntegration
          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\"]"}}
      
      Show
      1. Extract Reproducer.zip to any location 2. Build the project with Reproducer $ gradle|gradlew clean build 3. Start standard EAP 8.1.0 using standalone.bat 4. Deploy Reproducer\ear\build\libs\reproducer-eap8.ear 5. The deployment will fail with WFLYEJB0442: Unexpected Error 6. You will find the following in the log file ERROR [org.jboss.as.server] (management-handler-thread - 5) WFLYSRV0021: Deploy of deployment "reproducer-eap8.ear" was rolled back with the following failure message: {"WFLYCTL0080: Failed services" => {"jboss.deployment.subunit.\"reproducer-eap8.ear\".\"ejb.jar\".component.StartupBean.START" => "java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance Caused by: jakarta.ejb.EJBException: WFLYEJB0442: Unexpected Error Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.type.format.jackson.JacksonIntegration 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\"]"}}

      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
      

       

              lvydra Lukas Vydra
              rhn-support-wqueiroz Wagner Queiroz
              Votes:
              0 Vote for this issue
              Watchers:
              16 Start watching this issue

                Created:
                Updated: