• Call: +1 (858) 429-9131

Solr Error message – Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Sometimes when we follow the default steps to install Solr the MySQL JDBC libraries are missed out and we end up getting the following error in the log files.

 

 Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

 

We can get things working by following these steps.

 

Install the missing libraries

 

apt-get install libmysql-java

 

Find the required Jar files by using the following command

 

dpkg-query -L libmysql-java

 

This will give an output like the following

/.
/usr
/usr/share
/usr/share/java
/usr/share/java/mysql-connector-java-5.1.38.jar
/usr/share/doc
/usr/share/doc/libmysql-java
/usr/share/doc/libmysql-java/copyright
/usr/share/doc/libmysql-java/README.gz
/usr/share/doc/libmysql-java/changelog.Debian.gz
/usr/share/maven-repo
/usr/share/maven-repo/mysql
/usr/share/maven-repo/mysql/mysql-connector-java
/usr/share/maven-repo/mysql/mysql-connector-java/5.1.38
/usr/share/maven-repo/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.pom
/usr/share/maven-repo/mysql/mysql-connector-java/debian
/usr/share/maven-repo/mysql/mysql-connector-java/debian/mysql-connector-java-debian.pom
/usr/share/java/mysql.jar
/usr/share/java/mysql-connector-java.jar
/usr/share/maven-repo/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar
/usr/share/maven-repo/mysql/mysql-connector-java/debian/mysql-connector-java-debian.jar

 

From the above, the two jars mysql.jar and mysql-connector-java.jar are the ones which is needed.

create a soft link to the library path of your solr installation. (in this case, /opt/solr-6.6.0 )


cd /opt/solr-6.6.0/server/lib

ln -s /usr/share/java/mysql-connector-java-5.1.38.jar  /opt/solr-6.6.0/server/lib

ln -s /usr/share/java/mysql.jar /opt/solr-6.6.0/server/lib

 

Add the relevant path to your solrconfig.xml

 

<lib dir="${solr.install.dir:../../../..}/server/lib" regex=".*\.jar" />

restart Solr & you are all set.

 

In some cases, you will get an error

 

Caused by: java.sql.SQLException: Illegal value for setFetchSize().

This can be addressed by adding batchSize=”-1″ to the data source declaration.

 

ie,

 











Associated Links

  • Apache Solr

  • Leave a Reply