The code ran fine in two other Tomcat instances, but failed in a third one.
The error happened to be
ORA-03115: unsupported network datatype or representation
which basically means: There is a version mismatch between the database and the JDBC library.
Reason
That Tomcat instance had a copy of ojdbc14.jar in its lib/ subdirectory that was used instead of the ojdbc14.jar included in the application's *.war file.
Unfortunately it is hard to tell the version of an ojdbc14.jar from the outside.
Possible Solutions
- Unzip the ojdbc14.jar and check its manifest file.
- Get the version programmatically
Connection connection = ...;
DatabaseMetaData md = connection.getMetaData();
out.append(...md.getDriverName() + " " + md.getDriverVersion() ...);
That way it is possible at runtime to check which version you are actually using.
Moral
Don't put *.jar files in the Tomcat lib/ directory. Include them in the *.war file.
Yes, this way you might load multiple copies, one for each *.war, but that beats later wating time to debug an app that suddenly stops working because some Tomcat instance has the wrong *.jar in its lib/ directory.
No comments:
Post a Comment