0 Replies Latest reply on Nov 11, 2009 12:41 AM by Ru Ricky

    Jdbc Driver could not be instanced in Jboss5.1

    Ru Ricky Newbie

      Hi friends,

      Putting nzjdbc.jar(netezza database jdbc driver) in server/default/lib, I use this call to create the driver
      Class.forName("org.netezza.Driver").newInstance(). But I got a NoClassDefFoundError. Actually, I got the reason. the Driver has a static block which contains the following code and was executed when I was trying to load it.

      String str2 = Driver.class.getResource("Driver.class").getPath();

      int i = str2.lastindexOf("!");
      str2 = str2.substring(0,i);

      In jboss5.1, the first line of code will return /d:/nzjdbc.jar/org/netezza/Driver.class which does NOT contain "!" so, i will be -1, and the StringIndexOutOfBoundsException will be thrown at third line.
      I got a workaround for it that setting the nzjdbc.jar to system classpath or specifying nzjdbc.jar to wrapper.java.classpath.

      But in jboss4.2.0, the first line code will return file:/d/nzjdbc.jar!/org/netezza/Driver.class which contains the "!", so, everything was ok.

      My question is there any configuration in jboss to let server load the class with the JarClassLoader so that that code will return the path containing !


      Ricky Ru