The JDBC driver has to be visible to the same classloader as the data source factory itself. The data source factory library is placed in Tomcat’s own /lib
folder and thus loaded by Tomcat’s “common” classloader.
Your problem sounds much like that you dropped the JDBC driver in webapp’s /WEB-INF/lib
. The webapp’s /WEB-INF/lib
is invisible to the “common” classloader. So technically, you have to place the JDBC driver in Tomcat’s own /lib
folder (or, at least, in a configurable path as specified by common.loader
setting in /conf/catalina.properties
) in order to make it visible to the data source factory.
Or, as you attempted, copying the data source factory into /WEB-INF/lib
will also fix it. The webapp’s /WEB-INF/lib
has namely higher precedence in classloading than Tomcat’s /lib
folder. So if the data source factory is found in /WEB-INF/lib
, it will be loaded from there. As the JDBC driver is also there, it will be seen. This is however not the right solution to your concrete problem, this is more a workaround, so you shouldn’t do this.
There isn’t exactly documentation which is specifically targeted to this issue. The Tomcat Class Loader HOW-TO will however help in understanding the class loading hierarchy in Tomcat.