apache/seatunnel · error · SeaTunnelEngineException

Could not load service provider for factories.

Error message

Could not load service provider for factories.

What it means

Thrown by FactoryUtil.discoverFactory when the Java ServiceLoader mechanism fails with a ServiceConfigurationError while instantiating provider classes from META-INF/services files. This typically means a registered factory class could not be loaded/instantiated — its class is missing dependencies, is abstract, or threw in a static initializer.

Source

Thrown at seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/utils/FactoryUtil.java:86

            if (foundFactories.size() > 1) {
                throw new SeaTunnelEngineException(
                        String.format(
                                "Multiple factories for identifier '%s' that implement '%s' found in the classpath.\n\n"
                                        + "Ambiguous factory classes are:\n\n"
                                        + "%s",
                                factoryIdentifier,
                                factoryClass.getName(),
                                foundFactories.stream()
                                        .map(f -> f.getClass().getName())
                                        .sorted()
                                        .collect(Collectors.joining("\n"))));
            }

            return foundFactories.get(0);
        } catch (ServiceConfigurationError e) {
            log.error("Could not load service provider for factories.", e);
            throw new SeaTunnelEngineException("Could not load service provider for factories.", e);
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the logged cause (log.error prints the ServiceConfigurationError) to find which provider class failed and why.
  2. Install the missing dependency jars alongside the connector plugin.
  3. Re-download/reinstall the connector to repair a corrupted jar or truncated META-INF/services entry.
  4. Align SeaTunnel and plugin versions so shaded dependencies (org.apache.seatunnel.shade.*) resolve correctly.

Example fix

// before: plugin dir missing driver jar
connectors/connector-jdbc-2.3.8.jar
// after
connectors/connector-jdbc-2.3.8.jar
connectors/mysql-connector-java-8.0.29.jar (or driver in $SEATUNNEL_HOME/lib)
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check providers loadable
for (Class<?> f : ServiceLoader.load(FactoryClass.class, cl)) { /* instantiation happens here; failure surfaces early */ }

Try / catch

try { FactoryUtil.discoverFactory(f, cl, id); } catch (SeaTunnelEngineException e) { log.error("SPI provider failed to load; check missing dependency jars", e.getCause()); throw e; }

Prevention

When it happens

Trigger: Calling discoverFactory when a jar listed in META-INF/services references a factory class whose own dependencies are absent from the classpath, causing ServiceLoader.load/iteration to raise ServiceConfigurationError.

Common situations: Connector jar installed without its required dependency jars (e.g. JDBC driver or shaded deps); NoClassDefFoundError inside a factory's static block; incompatible shaded dependency versions breaking class loading.

Related errors


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