Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat 6 can't find mysql driver

There is a similar question here but regarding the class path. ClassNotFoundException com.mysql.jdbc.Driver

I've had everything working great until some days ago. Suddenly my little application can't find the mysql driver. And i don't understand why (really I've checked everything)

I got the driver jar in the WEB-INF/lib, but tomcat just seems unable to find it.

Anyone got any ideas why? I'm using Ubuntu with tomcat 6 and mysql installed from the synaptics packadge manager

The error that is giving is:

ClassNotFoundException: com.mysql.jdbc.Driver

I've even changed the permissions into 777 to see if it could be invisibile, but it isn't :(

like image 568
fmsf Avatar asked Dec 18 '22 04:12

fmsf


2 Answers

If you created a datasource which requires this driver, then it should be placed directly in the classpath of the container which manages the datasource. In this case, it's Tomcat which manages the datasource. Thus, with placing the driver in Tomcat/lib you'll be fine.

Apart from that, you told you're using Ubuntu. It ships by default with a GNU JDK. I would only highly recommend that you ensure that you get rid of it and install the Sun JDK instead. The GNU JDK is cluttered of bugs which may cause at first sight unexplainable problems. Hope you take this into consideration.

like image 139
BalusC Avatar answered Dec 19 '22 18:12

BalusC


Try putting the MySQL JDBC driver in $CATALINA_HOME/lib and restart the web server. Also, make sure the tomcat user (or whatever user you are running tomcat as) has permissions to read it.

like image 25
Asaph Avatar answered Dec 19 '22 17:12

Asaph