classForName(com.ibm.db2.jcc.DB2Driver) and external jars

Issues and Questions related to running Apache Tomcat on z/OS
Post Reply
alexp42
Posts: 4
Joined: Wed Apr 04, 2007 6:05 pm

classForName(com.ibm.db2.jcc.DB2Driver) and external jars

Post by alexp42 »

Hello!

I just encountered a very strange problem: I'm trying to use JDBC in my Tomcat Instance by using the classForName(com.ibm.db2.jcc.DB2Driver) to load the driver.

It works perfectly well - unless the classForName Code is in a .jar File I created remotely on Windows - I get a ClassNotFoundException. There is no problem with a .class File I compile on Windows and transfer via FTP.

Jars created on z/os issue no problems neither.

Strange, isn't it?

Any Idea?

Thanks!
Alex
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

This seems strange to me also.

Its most likely a subtle problem with your CLASSPATH. Try running with the "-verbose:class,Xclassdep" switch which should give you a classloader trace. Verify that the classes are being loaded from where you think they should be.
alexp42
Posts: 4
Joined: Wed Apr 04, 2007 6:05 pm

... it's the classpath, stupid ;-)

Post by alexp42 »

After hours of trying it out, I finally found the reason:

1) When trying to load a jdbc driver form a class file that is within a .jar file from the commandline, only the classpath in the manifest is considered.

2) In combination with Tomcat, I had to put the drivers (db2jcc.jar, db2jcc_javax.jar, db2jcc_license_cisuz.jar) in the TOMCAT_HOME/common/lib directory. Any other directory did not work out.

Hope that may help others, too.
Alex
Post Reply