Since I work on a few apps that use the DB2 JDBC Type 4 drivers, work-arounds for common issues have become familiar. But when the corrupted DB2 JAR issue resurfaced today, I realized that I had not posted about it. Now is as good a time as any to make up for that neglect…
The problem is that for DB2 LUW versions between 9 and 9.5, IBM published db2jcc.jar files with corrupt classes. In some Java EE environments, the container doesn’t fully scan JARs, so it doesn’t really matter if an unused class is wonky. But many containers do scan, causing exceptions like the following:
SEVERE: Unable to process Jar entry [COM/ibm/db2os390/sqlj/custom/DB2SQLJCustomizer.class] from Jar [jar:file:…lib/db2jcc.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is not a Java .class file
That particular exception is from Tomcat 7.
IBM acknowledges the problem (see http://www-01.ibm.com/support/docview.wss?uid=swg1LI72814) and offers a work-around: edit the JAR file to remove the offending classes.
Edit the JAR? Really?! A quicker, surer solution is to just grab a good JAR from http://www-01.ibm.com/support/docview.wss?uid=swg21363866.