{"record":{"id":"109f674a62c3ec3d","repo":"apache/seatunnel","slug":"failed-to-load-jdbc-driver-com-mysql-cj-jdbc-drive-109f67","errorCode":null,"errorMessage":"Failed to load JDBC driver com.mysql.cj.jdbc.Driver ","messagePattern":"Failed to load JDBC driver com\\.mysql\\.cj\\.jdbc\\.Driver ","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-tidb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBSourceFactory.java","lineNumber":96,"sourceCode":"    /**\n     * TODO: Implement SupportParallelism in the TableSourceFactory instead of the SeaTunnelSource,\n     * Then deprecated the method\n     */\n    @Override\n    public Class<? extends SeaTunnelSource> getSourceClass() {\n        return TiDBSource.class;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    @Override\n    public <T, SplitT extends SourceSplit, StateT extends Serializable>\n            TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {\n        return () -> {\n            // Load the JDBC driver in to DriverManager\n            try {\n                Class.forName(\"com.mysql.cj.jdbc.Driver\");\n            } catch (Exception e) {\n                log.warn(\"Failed to load JDBC driver com.mysql.cj.jdbc.Driver \", e);\n            }\n            ReadonlyConfig config = context.getOptions();\n            TiDBCatalogFactory catalogFactory = new TiDBCatalogFactory();\n            // Build tidb catalog.\n            TiDBCatalog catalog =\n                    (TiDBCatalog) catalogFactory.createCatalog(factoryIdentifier(), config);\n\n            TablePath tablePath =\n                    TablePath.of(\n                            config.get(TiDBSourceOptions.DATABASE_NAME),\n                            config.get(TiDBSourceOptions.TABLE_NAME));\n            CatalogTable catalogTable = catalog.getTable(tablePath);\n            return (SeaTunnelSource<T, SplitT, StateT>)\n                    new TiDBSource(context.getOptions(), catalogTable);\n        };\n    }\n}\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-tidb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBSourceFactory.java#L78-L114","documentation":"During TiDB source creation, the factory attempts Class.forName(\"com.mysql.cj.jdbc.Driver\") so the MySQL JDBC driver used by the TiDB CDC connector is registered with DriverManager. If the driver class is not on the classpath it logs this warning (it does not fail the job); the actual connection attempt later will throw a DriverManager-level error.","triggerScenarios":"Calling TiDBSourceFactory.createSource when the mysql-connector-java/mysql-connector-j jar is absent from the plugin/lib classpath (e.g. not installed via install-plugin.sh or missing from $SEATUNNEL_HOME/connectors and lib).","commonSituations":"Fresh SeaTunnel install without JDBC driver jar; connector fat jar built with mysql driver marked 'provided'; upgrading to MySQL Connector/J 8.x where the driver class moved from com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver.","solutions":["Add the MySQL Connector/J 8.x jar (mysql-connector-java-8.0.x / mysql-connector-j) to the connector classpath ($SEATUNNEL_HOME/connectors or lib directory).","Verify the driver coordinates/version match TiDB (MySQL 8.x protocol); rebuild shaded connector if driver scope is 'provided'.","Confirm the class name com.mysql.cj.jdbc.Driver exists in the jar (jar tf | grep Driver)."],"exampleFix":"<!-- before -->\n<scope>provided</scope>\n<!-- after -->\n<dependency>\n  <groupId>com.mysql</groupId>\n  <artifactId>mysql-connector-j</artifactId>\n  <version>8.0.33</version>\n</dependency>","handlingStrategy":"validation","validationCode":"// before submitting the job\ntry {\n    Class.forName(\"com.mysql.cj.jdbc.Driver\");\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"mysql-connector-j jar missing from classpath\", e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Install the MySQL Connector/J 8.x jar into $SEATUNNEL_HOME/connectors or lib before running TiDB CDC jobs","Use compile/runtime (not provided) scope for the driver in custom builds","Check this warning in startup logs when provisioning new clusters"],"tags":["jdbc","classpath","mysql-driver","cdc"],"backgroundTag":"class-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}