Query Processor fails to start due to missing MySQL JDBC driver

Condition

The Query Processor service is unable to load the JDBC driver. As a result, it cannot connect to the MySQL backend database.

The Query Processor service fails, displaying the following error message:

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

Cause

The Query Processor no longer includes the MySQL Connector/J JDBC driver by default due to licensing restrictions. As a result, the MySQL driver is not available on the Query Processor classpath when the service starts.

When the Query Processor attempts to initialize a connection to the MySQL backend, it fails because the required JDBC driver class (com.mysql.cj.jdbc.Driver) cannot be found. Since the driver is no longer shipped with the service, it must be manually provided in the Query Processor’s library directory.

To enable MySQL connectivity, you must manually provide a compatible MySQL Connector/J JDBC driver by placing it in the Query Processor, located at the following path:
/opt/cloudera/parcels/CDH/lib/hue-query-processor/lib/

Remedy

  1. Download a compatible MySQL Connector/J JDBC driver, for example, version 9.3.0.
  2. Copy the JAR file into the Query Processor library path by using the following command:
    cp mysql-connector-java.jar /opt/cloudera/parcels/CDH/lib/hue-query-processor/lib/
  3. Set the correct permissions for read and execute by using the following command:
    chmod 755 /opt/cloudera/parcels/CDH/lib/hue-query-processor/lib/mysql-connector-java.jar
  4. Verify that the required driver class exists by using the following command:
    jar tf mysql-connector-java.jar | grep com/mysql/cj/jdbc/Driver.class
  5. Restart the Query Processor service.