4 Replies Latest reply on Nov 18, 2014 7:40 AM by Benito Juarez

    java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver

    Benito Juarez Newbie




      i have trouble using the jdbc-odbc bridge in an own module:


      java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver from [Module "my.modules.jdbc:main" from local module loader @d6147e (roots: C:\Jboss\jboss-as-7.1.1.Final\modules)]


      Do u have a working scheme to add the needed dependency to my module?





        • 1. Re: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
          Wolf-Dieter Fink Master

          You might copy one of the module.xml files which contains dependencies.

          Your module should be located in modules/my/path.

          How your jar file and module.xml look like and where is your OdbcDriver?

          • 2. Re: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
            Benito Juarez Newbie

            it's not "my" driver, sun.jdbc.odbc.JdbcOdbcDriver comes from rt.jar (a core lib).

            But this package is hidden from module loader and must be included explicitly.


            Depart this issue, my module is located in the right directory and is working correctly.

            • 3. Re: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
              Jay SenSharma Master

              Hello Benito,


                   Try running the simple code in JDK 1.7 and JDK 1.6 to find the differences:


              Sample Code:



                public class Test {
                   public static void main(String ar[]) throws Exception {
                             Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                             System.out.println("Class Loaded Successfully, c = "+c);
                        } catch(Exception e) {
                             System.out.println("\n\t[ERROR] Class Failed to be Loaded");

              Output on JDK 1.7

              java -version
              java version "1.7.0_65"
              OpenJDK Runtime Environment (fedora- u65-b17)
              OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
              java Test
              java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
                  at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
                  at java.security.AccessController.doPrivileged(Native Method)
                  at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
                  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
                  at java.lang.Class.forName0(Native Method)
                  at java.lang.Class.forName(Class.java:190)
                  at Test.main(Test.java:4)
                  [ERROR] Class Failed to be Loaded


              Output on JDK 1.6


              java -version
              java version "1.6.0_30"
              Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
              Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
              java Test
              Class Loaded Successfully, c = class sun.jdbc.odbc.JdbcOdbcDriver



              What you can try?

              - So For JBoss AS7 version which you are using, Can you try something like following using JDK 1.6

              - So can you try running your JBoss AS7  on JDK 1.6  and also add the following line of code inside the "$JBOSS_HOME/modules/sun/jdk/main/module.xml" add the following Path  (In later versions of JBoss AS7 you will find these paths are already added):


                              <path name="sun/jdbc/odbc"/>
                              <path name="sun/jdbc/odbc/ee"/>



              - In your applications "jboss-deployment-structure.xml" add the "sun.jdk" dependency as following:


              <?xml version="1.0" ?>
              <module xmlns="urn:jboss:module:1.1" name="my.modules" slot="main">
                      <resource-root path="YOUR_JARs.jar"/>
                      <module name="sun.jdk"/>        <!--  ADDED -->
              • 4. Re: java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
                Benito Juarez Newbie

                Hello Jay,


                your solution works for me.

                thx a lot!