{"record":{"id":"f16cf444cfa91116","repo":"apache/seatunnel","slug":"failed-to-load-jdbc-driver-com-mysql-cj-jdbc-drive","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-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlIncrementalSourceFactory.java","lineNumber":122,"sourceCode":"                        SourceOptions.STARTUP_TIMESTAMP)\n                .build();\n    }\n\n    @Override\n    public Class<? extends SeaTunnelSource> getSourceClass() {\n        return MySqlIncrementalSource.class;\n    }\n\n    @Override\n    public <T, SplitT extends SourceSplit, StateT extends Serializable>\n            TableSource<T, SplitT, StateT> restoreSource(\n                    TableSourceFactoryContext context, List<CatalogTable> restoreTables) {\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            List<CatalogTable> catalogTables =\n                    CatalogTableUtil.getCatalogTables(config, context.getClassLoader());\n            boolean enableSchemaChange =\n                    context.getOptions()\n                            .getOptional(SourceOptions.SCHEMA_CHANGES_ENABLED)\n                            .orElse(\n                                    // TODO remove this after all users used the new schema change\n                                    // option\n                                    context.getOptions()\n                                            .getOptional(SourceOptions.DEBEZIUM_PROPERTIES)\n                                            .map(\n                                                    e ->\n                                                            e.getOrDefault(\n                                                                    MySqlSourceConfigFactory\n                                                                            .SCHEMA_CHANGE_KEY,\n                                                                    SourceOptions","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlIncrementalSourceFactory.java#L104-L140","documentation":"MySqlIncrementalSourceFactory.restoreSource() attempts to force-load the MySQL Connector/J driver (com.mysql.cj.jdbc.Driver) via Class.forName so it is registered with DriverManager. When the class cannot be found (or another exception occurs during loading) it logs this warning with the exception, then continues — the driver must already be on the classpath or a later connection attempt will fail.","triggerScenarios":"restoreSource() calls Class.forName(\"com.mysql.cj.jdbc.Driver\") and the call throws ClassNotFoundException/LinkageError because the mysql-connector-java/mysql-connector-j artifact is not on the classpath of the SeaTunnel job.","commonSituations":"MySQL JDBC driver jar not installed in $SEATUNNEL_HOME/connectors/connector-plugin or lib/; driver bundled only transitively and excluded by shading; running a custom job with the cdc-mysql connector jar but not the driver; version conflicts removing the cj driver (old com.mysql.jdbc.Driver only).","solutions":["Add mysql-connector-java (8.x, com.mysql.cj.jdbc.Driver) to the classpath: copy mysql-connector-j-8.x.jar into $SEATUNNEL_HOME/lib/ (or the plugin dir) on all nodes.","Declare the dependency (com.mysql:mysql-connector-j) in your job's build if submitting a fat jar.","Check for conflicting older mysql connectors (mysql-connector-java 5.x provides com.mysql.jdbc.Driver, not com.mysql.cj.jdbc.Driver).","Re-run with -e local or check logs for the chained exception to see if it is ClassNotFoundException vs LinkageError."],"exampleFix":"// before (pom.xml)\n<!-- no mysql driver -->\n// after (pom.xml)\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 submission, check driver presence:\nClass.forName(\"com.mysql.cj.jdbc.Driver\");\n// or shell: unzip -l seatunnel/lib/mysql-connector-j-*.jar | grep com/mysql/cj/jdbc/Driver","typeGuard":null,"tryCatchPattern":"try {\n    Class.forName(\"com.mysql.cj.jdbc.Driver\");\n} catch (ClassNotFoundException e) {\n    throw new IllegalStateException(\"MySQL JDBC driver missing from classpath\", e);\n}","preventionTips":["Copy mysql-connector-j 8.x into $SEATUNNEL_HOME/lib on every node","Do not exclude/shade out com.mysql artifacts from your fat jar","Pin driver 8.x (com.mysql.cj.jdbc.Driver); 5.x only has com.mysql.jdbc.Driver","Verify the jar ships with the job before submitting to the cluster"],"tags":["mysql","jdbc","classpath","dependency"],"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-14T16:17:12.679Z"}