Tomcat on Debian and Ubuntu Linux – Fix Broken com.mysql.jdbc.Driver Connection

By | 2014/02/20

Getting java.lang.ClassNotFoundException: “com.mysql.jdbc.Driver” or similar error on Debian? Debian and Ubuntu provide complete Apache Tomcat packages including the java mysql connector. However, the default Tomcat config does not find the provided mysql connector! Here is a fix.


1. First, this assumes you have tomcat and the mysql connector installed:

$ sudo apt-get install tomcat7 tomcat7-admin libmysql-java

The mysql connector is installed to /usr/share/java/ .


2. Next, create a symlink as below:

sudo ln -s /usr/share/java/mysql-connector-java.jar /var/lib/tomcat7/commons/mysql-connector-java.jar


3. Restart tomcat:

$ sudo /etc/init.d/tomcat7 restart

Done! Now your app should be able to connect to a mysql database.

I will submit a bug report for this on Launchpad soon.