Solve java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Recently I faced a problem regarding jdbc mySql connector. The error above kept popping in my Tomcat 7 console.

I created a web app using Maven 3 Spring 3 Hibernate 3 using the following URL:

Until now everything is great, but the error above popped again. Then in the project’s classpath in libraries tab I went to Add Variable and I chose Extend. In this window I added in M2_REPO the jar file from mysql folder in the repository. The console still displayed the same error.

After few minutes of searching I found the solution. The solution is that you have to copy the jar in lib folder from CATALINA_HOME.

So, although you’d expect MAVEN to handle this it seems it doesn’t so you have to do it manually.


Andrei Visan.