No suitable drivers found for jdbc: mysql: // localhost: 3306 / test


When i try to run my JSF application on Tomcat 7, it throws this exception.

Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(
... 51 more

If I add this line before creating EntitiyManagerFactory, it works fine.

emf = Persistence.createEntityManagerFactory("manager1");

My dependencies are



Also my application works fine tomcat 6, without adding Class.forName("com.mysql.jdbc.Driver");

Any idea to solve this problem? Thanks

First and real solution: Try with Hibernate 4.1.0 and 4.1.3.Final.

I ran into this issue on Hibernate 4.1.2 before eventually stumbling across As far as I can see, it's a bit of an incompatibility between the later versions of Tomcat (In its fixes for the leaky nature of the DeviceManager) and Hibernate 4.1.2.

The other workarounds are to invoke the registration of the driver explicitly, as in Brad Whitaker's answer, or to make sure the JreMemoryLeakPreventionListener isn't protecting the DriverManager by adding driverManagerProtection="false" to the Listener definition in $CATALINA_HOME/conf/server.xml - that is:

<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" driverManagerProtection="false">