tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: java.sql.SQLException: No suitable driver found for in tomcat 6.0.35, is the class loading changed?
Date Thu, 22 Dec 2011 23:06:19 GMT
Hash: SHA1


On 12/16/11 7:49 PM, Frank Zhang wrote:
> Our code is using apache dbcp library and mysql-connector as JDBC 
> driver other than tomcat own tomcat-dbcp.jar.

Are you attempting to use the classes in tomcat-dbcp.jar directly? Or,
do you just mean that you are using a JNDI DataSource set up in your
<Context> element, and so Tomcat is using tomcat-dbcp.jar?

> we always put mysql-connector at CATALINA_HOME/lib

Good, if you are letting Tomcat configure your DataSource.

> while put commons-dbcp-1.4.jar at
> CATALINA_HOME/webapps/client/WEB-INF/lib/.

Well, if you expect to use commons-dbcp directly, then this is
probably what you should do. If you are just using Tomcat's JNDI
DataSource, then you don't need this library anywhere at all.

> This worked fairly well in tomcat 6.0.2x and even in 6.0.33. In
> 6.0.35 I encountered the error "java.sql.SQLException: No suitable
> driver found for" during the booting time which looks like
> mysql-connector not in classpath.

CATALINA_HOME/lib will be in the CLASSPATH for Tomcat's ClassLoader,
which will be used after your webapp's ClassLoader, depending on
exactly when the driver tries to load.

> Considering it's working all right before, my suspect is 6.0.35 
> silently changed its class loading way. Could somebody give me
> some hints? Thanks.

I suspect nothing has changed in Tomcat.

> Accidentally, I tried putting mysql-connector to 
> CATALINA_HOME/webapps/client/WEB-INF/lib/,  but no better result.

If you are using a JNDI DataSource, you should probably have it in
CATALINA_HOME/lib and nowhere else.

> [java] java.sql.SQLException: No suitable driver found for
> jdbc:mysql://localhost:3306/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true
[java]     at java.sql.DriverManager.getConnection(
> [java]     at
> java.sql.DriverManager.getConnection( [java]
> at
> org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(
[java]     at
> [java]     at
> org.apache.commons.pool.impl.GenericObjectPool.borrowObject(
[java]     at
> [java]     at

that looks like you are NOT using a Tomcat-created JNDI
DataSource, but instead using commons-dbcp directly. I don't think you
are using tomat-dbcp.jar at all, since those aren't the right class names.

Given that, I would expect you to put both the driver *and*
commons-dbcp.jar into your webapp's WEB-INF/lib directory. Make sure
that neither of those JAR files are also found in CATALINA_HOME/lib.

Can you re-confirm your current setup?

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message