apache/seatunnel · warning
Failed to load JDBC driver com.mysql.cj.jdbc.Driver
Error message
Failed to load JDBC driver com.mysql.cj.jdbc.Driver
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-mysql/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/mysql/source/MySqlIncrementalSourceFactory.java:122
SourceOptions.STARTUP_TIMESTAMP)
.build();
}
@Override
public Class<? extends SeaTunnelSource> getSourceClass() {
return MySqlIncrementalSource.class;
}
@Override
public <T, SplitT extends SourceSplit, StateT extends Serializable>
TableSource<T, SplitT, StateT> restoreSource(
TableSourceFactoryContext context, List<CatalogTable> restoreTables) {
return () -> {
// Load the JDBC driver in to DriverManager
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (Exception e) {
log.warn("Failed to load JDBC driver com.mysql.cj.jdbc.Driver ", e);
}
ReadonlyConfig config = context.getOptions();
List<CatalogTable> catalogTables =
CatalogTableUtil.getCatalogTables(config, context.getClassLoader());
boolean enableSchemaChange =
context.getOptions()
.getOptional(SourceOptions.SCHEMA_CHANGES_ENABLED)
.orElse(
// TODO remove this after all users used the new schema change
// option
context.getOptions()
.getOptional(SourceOptions.DEBEZIUM_PROPERTIES)
.map(
e ->
e.getOrDefault(
MySqlSourceConfigFactory
.SCHEMA_CHANGE_KEY,
SourceOptionsView on GitHub (pinned to cf67b549a7)
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.
Example fix
// before (pom.xml) <!-- no mysql driver --> // after (pom.xml) <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> <version>8.0.33</version> </dependency>
Defensive patterns
Strategy: validation
Validate before calling
// Before submission, check driver presence:
Class.forName("com.mysql.cj.jdbc.Driver");
// or shell: unzip -l seatunnel/lib/mysql-connector-j-*.jar | grep com/mysql/cj/jdbc/Driver Try / catch
try {
Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
throw new IllegalStateException("MySQL JDBC driver missing from classpath", e);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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).
Related errors
- Failed to load JDBC driver com.mysql.cj.jdbc.Driver
- Failed to load JDBC driver {}
- Failed to load JDBC driver com.mysql.cj.jdbc.Driver
- Failed to load JDBC driver {}
- Could not load service provider for factories.
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/f16cf444cfa91116.
Report an issue: GitHub.