Unable to connect to MySQL database - Exception attempting to load Database driver
Symptoms
Migrating to MySQL database fails and the following error is displayed in the web interface:
Unable to load database driver from your FISHEYE_INST/lib directory. Please check the JDBC driver jar is properly installed
The following warning is written in the FISHEYE_INST/var/log/atlassian-fisheye-<date>.log
:
2022-04-17 10:34:27,237 WARN [qtp1052317717-181 ] fisheye TestDBConnectionAjaxAction-checkDriverClass - Exception attempting to load Database driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) [?:1.8.0_241]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) [?:1.8.0_241]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [?:1.8.0_241]
at java.lang.Class.forName0(Native Method) [?:1.8.0_241]
at java.lang.Class.forName(Class.java:348) [?:1.8.0_241]
at com.atlassian.crucible.actions.admin.database.TestDBConnectionAjaxAction.checkDriverClass(TestDBConnectionAjaxAction.java:57) [fisheye.jar:?]
at com.atlassian.crucible.actions.admin.database.TestDBConnectionAjaxAction.execute(TestDBConnectionAjaxAction.java:31) [fisheye.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [?:1.8.0_241]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [?:1.8.0_241]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [?:1.8.0_241]
at java.lang.reflect.Method.invoke(Method.java:498) [?:1.8.0_241]
...(truncated)
Environment
Fisheye / Crucible 2.9.x or newer.
Cause
As can be seen at Migrating to MySQL - Prerequisites, starting with Fisheye 2.9.x, the JDBC driver for MySQL is no longer bundled with Fisheye/Crucible due to MySQL licensing restrictions.
Resolution
Manually download and install the MySQL Connector/J JDBC driver version 5.1.49 because 8.x is known to cause issues.
Follow these steps:
- Stop Fisheye / Crucible
- Download the MySQL Connector/J JDBC driver 5.1.49 from this direct download link or access the download website, switch the Product Version dropdown to 5.1.49 and click the Download button.
- Expand the downloaded
zip / tar.gz
file. - Copy the
mysql-connector-java-5.1.XX-bin.jar
file from the extracted directory to yourFISHEYE_INST
/lib
directory- Remember that
FISHEYE_INST
is an environment variable which points to Fisheye's data directory - You may need to create the
lib
directory insideFISHEYE_INST
- Remember that
- Make sure that the user who starts Fisheye/Crucible has the proper file system permission to execute the jar file
Start Fisheye / Crucible