2 Replies Latest reply on Nov 8, 2018 4:24 AM by Thorsten Heit

    Wildfly 11 + 14: ClassNotFoundException in EAR when using Java 9

    Thorsten Heit Newbie

      Hi,

       

      I have an EAR that uses a third-party library which contains a lot of obfuscated code. This library loads classes dynamically during runtime as far as I can tell. Everything works on my machine when I start Wildfly 11 or 14 from within Eclipse (2018-09) using Java 8. So far, so good.

       

      Now I wanted to give Java 9 a try, but then Wildfly refuses to start the EAR because of a (IMHO) very strange ClassNotFoundException in said third-party library:

       

      (...)

      15:29:06,279 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 74) MSC000001: Failed to start service jboss.deployment.subunit."myapp-2018.3.0-SNAPSHOT.ear"."myapp-war-2018.3.0-SNAPSHOT.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.subunit."myapp-2018.3.0-SNAPSHOT.ear"."myapp-war-2018.3.0-SNAPSHOT.war".undertow-deployment: java.lang.NoClassDefFoundError: java/sql/Driver

          at org.wildfly.extension.undertow@14.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)

          at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:514)

          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)

          at org.jboss.threads@2.3.2.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)

          at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)

          at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)

          at org.jboss.threads@2.3.2.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)

          at java.base/java.lang.Thread.run(Thread.java:844)

          at org.jboss.threads@2.3.2.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485)

      Caused by: java.lang.NoClassDefFoundError: java/sql/Driver

          at java.base/java.lang.ClassLoader.defineClass1(Native Method)

          at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1007)

          at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)

          at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:545)

          at java.base/java.net.URLClassLoader.access$100(URLClassLoader.java:83)

          at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:453)

          at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:447)

          at java.base/java.security.AccessController.doPrivileged(Native Method)

          at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:446)

          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:563)

          at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)

          at java.base/java.lang.Class.forName0(Native Method)

          at java.base/java.lang.Class.forName(Class.java:375)

      (...)

      I already searched a lot, but couldn't find a valid answer what is causing this error...

       

      According to Class Loading in WildFly - Latest WildFly Documentation - Project Documentation Editor (Accessing JDK classes) not all JDK classes are exposed to a deployment by default. So I tried to make the package java.sql availble to the EAR in my jboss-deployment-structure.xml, but without success:

       

      <jboss-deployment-structure
          xmlns="urn:jboss:deployment-structure:1.2">
          <deployment>
              <exclude-subsystems>
                  <subsystem name="webservices" />
              </exclude-subsystems>
              <dependencies>
                  <module name="javax.xml.ws.api" export="true" />
                  <module name="javax.jws.api" export="true" />
                  <module name="com.ibm.db2" export="true" />
                  <system export="true">
                      <paths>
                          <path name="java/sql" />
                      </paths>
                  </system>
              </dependencies>
          </deployment>
      </jboss-deployment-structure>
      
      

       

      Does anybody have an idea what I'm doing wrong?

       

       

      Best regards

       

      Thorsten