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

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.

Source

Thrown at seatunnel-connectors-v2/connector-cdc/connector-cdc-tidb/src/main/java/org/apache/seatunnel/connectors/seatunnel/cdc/tidb/source/TiDBSourceFactory.java:96

    /**
     * TODO: Implement SupportParallelism in the TableSourceFactory instead of the SeaTunnelSource,
     * Then deprecated the method
     */
    @Override
    public Class<? extends SeaTunnelSource> getSourceClass() {
        return TiDBSource.class;
    }

    @SuppressWarnings("unchecked")
    @Override
    public <T, SplitT extends SourceSplit, StateT extends Serializable>
            TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) {
        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();
            TiDBCatalogFactory catalogFactory = new TiDBCatalogFactory();
            // Build tidb catalog.
            TiDBCatalog catalog =
                    (TiDBCatalog) catalogFactory.createCatalog(factoryIdentifier(), config);

            TablePath tablePath =
                    TablePath.of(
                            config.get(TiDBSourceOptions.DATABASE_NAME),
                            config.get(TiDBSourceOptions.TABLE_NAME));
            CatalogTable catalogTable = catalog.getTable(tablePath);
            return (SeaTunnelSource<T, SplitT, StateT>)
                    new TiDBSource(context.getOptions(), catalogTable);
        };
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. 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).
  2. Verify the driver coordinates/version match TiDB (MySQL 8.x protocol); rebuild shaded connector if driver scope is 'provided'.
  3. Confirm the class name com.mysql.cj.jdbc.Driver exists in the jar (jar tf | grep Driver).

Example fix

<!-- before -->
<scope>provided</scope>
<!-- after -->
<dependency>
  <groupId>com.mysql</groupId>
  <artifactId>mysql-connector-j</artifactId>
  <version>8.0.33</version>
</dependency>
Defensive patterns

Strategy: validation

Validate before calling

// before submitting the job
try {
    Class.forName("com.mysql.cj.jdbc.Driver");
} catch (ClassNotFoundException e) {
    throw new IllegalStateException("mysql-connector-j jar missing from classpath", e);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/109f674a62c3ec3d. Report an issue: GitHub.