Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-17038

[HHH-15543] Hibernate fails to initialize without access to Oracle JDBC driver classes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • JPA / Hibernate
    • None
    • Hide

      JDBC driver deployed as module (ojdbc10.jar - version 10.16.0.0).

      <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.1" name="jdbc">
        <resources>
          <resource-root path="jdbc_driver.jar"/>
        </resources>
        <dependencies>
          <module name="javax.api"/>
          <module name="jakarta.transaction.api"/>
          <module name="sun.jdk"/>
          <module name="ibm.jdk"/>
          <module name="javax.xml.bind.api"/>
        </dependencies>
      </module>
      

      Simple JPA application:

      <?xml version="1.0" encoding="UTF-8"?>
      <persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
        <persistence-unit name="defaultPU" transaction-type="JTA">
          <jta-data-source>java:/jboss/datasources/TestDatasource</jta-data-source>
          <exclude-unlisted-classes>true</exclude-unlisted-classes>
          <class>org.jboss.qa.datasource.tests.deployment.jpa.TestEntity</class>
          <properties>
            <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
              <property name="hibernate.show_sql" value="true"/>
          </properties>
        </persistence-unit>
      </persistence>
      
      

       

      datasource:

      <datasource jndi-name="java:jboss/datasources/TestDatasource" pool-name="TestDatasource" spy="true" statistics-enabled="true">
          <connection-url>url</connection-url>
          <driver>jdbc_driver</driver>
          <pool>
              <min-pool-size>0</min-pool-size>
              <max-pool-size>1</max-pool-size>
              <prefill>false</prefill>
              <allow-multiple-users>true</allow-multiple-users>
          </pool>
          <security>
              <user-name>user</user-name>
              <password>password</password>
          </security>
      </datasource>
      <drivers>
          <driver name="jdbc_driver" module="jdbc"/>
      </drivers>
      
      
      Show
      JDBC driver deployed as module (ojdbc10.jar - version 10.16.0.0). <?xml version= "1.0" encoding= "UTF-8" ?> <module xmlns= "urn:jboss:module:1.1" name= "jdbc" >   <resources>     <resource-root path= "jdbc_driver.jar" />   </resources>   <dependencies>     <module name= "javax.api" />     <module name= "jakarta.transaction.api" />     <module name= "sun.jdk" />     <module name= "ibm.jdk" />     <module name= "javax.xml.bind.api" />   </dependencies> </module> Simple JPA application: <?xml version= "1.0" encoding= "UTF-8" ?> <persistence version= "3.0" xmlns= "https://jakarta.ee/xml/ns/persistence" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd" >   <persistence-unit name= "defaultPU" transaction-type= "JTA" >     <jta-data-source> java:/jboss/datasources/TestDatasource </jta-data-source>     <exclude-unlisted-classes> true </exclude-unlisted-classes>     <class> org.jboss.qa.datasource.tests.deployment.jpa.TestEntity </class>     <properties>       <property name= "hibernate.hbm2ddl.auto" value= "create-drop" />         <property name= "hibernate.show_sql" value= "true" />     </properties>   </persistence-unit> </persistence>   datasource: <datasource jndi-name= "java:jboss/datasources/TestDatasource" pool-name= "TestDatasource" spy= "true" statistics-enabled= "true" >     <connection-url> url </connection-url>     <driver> jdbc_driver </driver>     <pool>         <min-pool-size> 0 </min-pool-size>         <max-pool-size> 1 </max-pool-size>         <prefill> false </prefill>         <allow-multiple-users> true </allow-multiple-users>     </pool>     <security>         <user-name> user </user-name>         <password> password </password>     </security> </datasource> <drivers>     <driver name= "jdbc_driver" module= "jdbc" /> </drivers>
    • Workaround Exists
    • Hide

      I guess multiple workarounds:

      • Name of the module with jdbc driver must be "com.oracle.ojdbc" (WFLY-16752) I guess it is usable only when driver is added as module, not when it is deployed as deployment
      • make module global, it should work also for drivers deployed as deployment
      Show
      I guess multiple workarounds: Name of the module with jdbc driver must be "com.oracle.ojdbc" ( WFLY-16752 ) I guess it is usable only when driver is added as module, not when it is deployed as deployment make module global, it should work also for drivers deployed as deployment
    • ---
    • ---

      WildFly wildfly-27.0.0.Beta1-SNAPSHOT built from 56f2ed05dbf37793cacb830199d62746ec790adb

      11:13:11,418 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 74) MSC000001: Failed to start service jboss.persistenceunit."test-277185d5-f294-411d-9ea8-332708db759f.war#defaultPU": org.jboss.msc.service.StartException in service jboss.persistenceunit."test-277185d5-f294-411d-9ea8-332708db759f.war#defaultPU": java.lang.ExceptionInInitializerError
              at org.jboss.as.jpa@27.0.0.Beta1-SNAPSHOT//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:199)
              at org.jboss.as.jpa@27.0.0.Beta1-SNAPSHOT//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:129)
              at java.base/java.security.AccessController.doPrivileged(Native Method)
              at org.wildfly.security.elytron-base@2.0.0.Final//org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:664)
              at org.jboss.as.jpa@27.0.0.Beta1-SNAPSHOT//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:214)
              at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
              at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
              at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
              at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
              at java.base/java.lang.Thread.run(Thread.java:829)
              at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)
      Caused by: java.lang.ExceptionInInitializerError
              at org.hibernate@6.1.3.Final//org.hibernate.dialect.OracleDialect.contributeTypes(OracleDialect.java:723)
              at org.hibernate@6.1.3.Final//org.hibernate.boot.model.process.spi.MetadataBuildingProcess.handleTypes(MetadataBuildingProcess.java:386)
              at org.hibernate@6.1.3.Final//org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:143)
              at org.hibernate@6.1.3.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1350)
              at org.hibernate@6.1.3.Final//org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1421)
              at org.hibernate.jipijapa-hibernate6@27.0.0.Beta1-SNAPSHOT//org.jboss.as.jpa.hibernate.TwoPhaseBootstrapImpl.build(TwoPhaseBootstrapImpl.java:45)
              at org.jboss.as.jpa@27.0.0.Beta1-SNAPSHOT//org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1$1.run(PersistenceUnitServiceImpl.java:171)
              ... 10 more
      Caused by: java.lang.RuntimeException: Couldn't initialize OracleArrayJdbcType
              at org.hibernate@6.1.3.Final//org.hibernate.dialect.OracleArrayJdbcType.<clinit>(OracleArrayJdbcType.java:62)
              ... 17 more
      Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleConnection from [Module "org.hibernate" version 6.1.3.Final from local module loader @7b420819 (finder: local module finder @7a1a14a4 (roots: /tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules,/tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules/system/layers/base))]
              at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:200)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:410)
              at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
              at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
              at java.base/java.lang.Class.forName0(Native Method)
              at java.base/java.lang.Class.forName(Class.java:315)
              at org.hibernate@6.1.3.Final//org.hibernate.dialect.OracleArrayJdbcType.<clinit>(OracleArrayJdbcType.java:58)
              ... 17 more
      
      11:13:11,421 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "test-277185d5-f294-411d-9ea8-332708db759f.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"test-277185d5-f294-411d-9ea8-332708db759f.war#defaultPU\"" => "java.lang.ExceptionInInitializerError
          Caused by: java.lang.ExceptionInInitializerError
          Caused by: java.lang.RuntimeException: Couldn't initialize OracleArrayJdbcType
          Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleConnection from [Module \"org.hibernate\" version 6.1.3.Final from local module loader @7b420819 (finder: local module finder @7a1a14a4 (roots: /tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules,/tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules/system/layers/base))]"}}
      11:13:11,421 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "test-277185d5-f294-411d-9ea8-332708db759f.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"test-277185d5-f294-411d-9ea8-332708db759f.war#defaultPU\"" => "java.lang.ExceptionInInitializerError
          Caused by: java.lang.ExceptionInInitializerError
          Caused by: java.lang.RuntimeException: Couldn't initialize OracleArrayJdbcType
          Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleConnection from [Module \"org.hibernate\" version 6.1.3.Final from local module loader @7b420819 (finder: local module finder @7a1a14a4 (roots: /tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules,/tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules/system/layers/base))]"}}
      11:13:11,422 ERROR [org.jboss.as.server] (management-handler-thread - 1) WFLYSRV0021: Deploy of deployment "test-277185d5-f294-411d-9ea8-332708db759f.war" was rolled back with the following failure message: 
      {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"test-277185d5-f294-411d-9ea8-332708db759f.war#defaultPU\"" => "java.lang.ExceptionInInitializerError
          Caused by: java.lang.ExceptionInInitializerError
          Caused by: java.lang.RuntimeException: Couldn't initialize OracleArrayJdbcType
          Caused by: java.lang.ClassNotFoundException: oracle.jdbc.OracleConnection from [Module \"org.hibernate\" version 6.1.3.Final from local module loader @7b420819 (finder: local module finder @7a1a14a4 (roots: /tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules,/tmp/wildfly-27.0.0.Beta1-SNAPSHOT/modules/system/layers/base))]"}}\
      
      

      WFLY-16752 added optional dependency on driver modules to hibernate modules, but modules with drivers must have proper expected names. Also it doesn't help with drivers that are deployed as deployments (WFLY-16751 might be for this use, but I'm not sure).

              smarlow1@redhat.com Scott Marlow
              msimka@redhat.com Martin Simka
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: