{"record":{"id":"4b8f930950ee8817","repo":"prestodb/presto","slug":"jdbc-driver-class-not-found-config-getjdbcdriver","errorCode":null,"errorMessage":"JDBC driver class not found: {config.getJdbcDriverName()}","messagePattern":"JDBC driver class not found: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"presto-db-session-property-manager/src/main/java/com/facebook/presto/session/db/SessionPropertiesDaoProvider.java","lineNumber":41,"sourceCode":"\nimport static java.util.Objects.requireNonNull;\n\npublic class SessionPropertiesDaoProvider\n        implements Provider<SessionPropertiesDao>\n{\n    private final SessionPropertiesDao dao;\n\n    @Inject\n    public SessionPropertiesDaoProvider(DbSessionPropertyManagerConfig config)\n    {\n        requireNonNull(config, \"config is null\");\n        requireNonNull(config.getConfigDbUrl(), \"db url is null\");\n\n        try {\n            Class.forName(config.getJdbcDriverName());\n        }\n        catch (ClassNotFoundException e) {\n            throw new RuntimeException(\"JDBC driver class not found: \" + config.getJdbcDriverName(), e);\n        }\n\n        this.dao = Jdbi.create(() -> DriverManager.getConnection(config.getConfigDbUrl()))\n                .installPlugin(new SqlObjectPlugin())\n                .onDemand(SessionPropertiesDao.class);\n    }\n\n    @Override\n    public SessionPropertiesDao get()\n    {\n        return dao;\n    }\n}\n","sourceCodeStart":23,"sourceCodeEnd":55,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-db-session-property-manager/src/main/java/com/facebook/presto/session/db/SessionPropertiesDaoProvider.java#L23-L55","documentation":"SessionPropertiesDaoProvider connects to the config database over JDBC using Jdbi. Before creating connections it calls Class.forName on the configured driver class so DriverManager can load it. If the driver class named in config.getJdbcDriverName() is not on the classpath, the provider throws a RuntimeException wrapping the ClassNotFoundException during construction, so the DB-backed session property manager fails to initialize.","triggerScenarios":"Constructing SessionPropertiesDaoProvider (via its public constructor, e.g. in the Guice module) when config.getJdbcDriverName() names a class absent from the classpath; usually a MySQL/Postgres driver jar missing at server startup.","commonSituations":"Deployment without the JDBC driver jar (e.g. MySQL connector not packaged or not on the plugin classpath); typo in the driver class name in config properties; switching databases (MySQL to Postgres) without changing the driver config; shaded/uber-jar that excludes JDBC drivers.","solutions":["Add the JDBC driver jar matching config.getJdbcDriverName() to the server/plugin classpath (e.g. mysql-connector-j or postgresql)","Verify the driver class name in configuration is correct and fully qualified (e.g. com.mysql.cj.jdbc.Driver, org.postgresql.Driver)","Check the deployment artifact/build to ensure the driver dependency is included and not marked provided/excluded","Restart the coordinator after adding the driver so the classloader picks it up"],"exampleFix":"// before (config.properties)\nsession-property-manager.db.url=jdbc:mysql://db:3306/config\n# driver jar missing\n// after\n# add mysql-connector-j.jar to the plugin/classpath and set\ndb.session-properties.jdbc-driver-name=com.mysql.cj.jdbc.Driver","handlingStrategy":"validation","validationCode":"String driverName = config.getJdbcDriverName();\ntry {\n    Class.forName(driverName);\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"JDBC driver not on classpath: \" + driverName\n        + \". Add the driver jar to the plugin/classpath.\", e);\n}","typeGuard":"boolean isJdbcDriverPresent(String driverClass) {\n    try { Class.forName(driverClass); return true; }\n    catch (ClassNotFoundException e) { return false; }\n}","tryCatchPattern":"try {\n    new SessionPropertiesDaoProvider(config, ...);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"JDBC driver class not found\")) {\n        // log actionable hint: check getJdbcDriverName() and classpath\n        throw new ConfigurationException(\"Add the JDBC driver jar named in config to the classpath\", e);\n    }\n    throw e;\n}","preventionTips":["Ship the JDBC driver jar with the deployment and verify it in the startup script or Docker image","Pin and double-check the fully qualified driver class name in config (com.mysql.cj.jdbc.Driver vs com.mysql.jdbc.Driver)","Smoke-test DB-backed session property manager init in CI with the same classpath as production","Keep driver dependency scope correct (runtime, not provided) in the build"],"tags":["jdbc","classpath","configuration","startup"],"backgroundTag":"jdbc-driver-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}