apache/seatunnel · error · SeaTunnelEngineException

Failed to call factoryIdentifier method.

Error message

Failed to call factoryIdentifier method.

What it means

Thrown by FactoryUtil.discoverFactory while filtering SPI-discovered factory instances: it reflectively invokes each candidate's factoryIdentifier() method, and any IllegalAccessException, InvocationTargetException, or NoSuchMethodException is wrapped in a SeaTunnelEngineException. This indicates a factory on the classpath whose class is broken or does not expose the expected factoryIdentifier method.

Source

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

            ClassLoader classLoader, Class<T> factoryClass, String factoryIdentifier) {
        try {
            final List<T> result = new LinkedList<>();
            ServiceLoader.load(factoryClass, classLoader).iterator().forEachRemaining(result::add);

            List<T> foundFactories =
                    result.stream()
                            .filter(f -> factoryClass.isAssignableFrom(f.getClass()))
                            .filter(
                                    t -> {
                                        try {
                                            return t.getClass()
                                                    .getMethod("factoryIdentifier")
                                                    .invoke(t)
                                                    .equals(factoryIdentifier);
                                        } catch (IllegalAccessException
                                                | InvocationTargetException
                                                | NoSuchMethodException e) {
                                            throw new SeaTunnelEngineException(
                                                    "Failed to call factoryIdentifier method.");
                                        }
                                    })
                            .collect(Collectors.toList());

            if (foundFactories.isEmpty()) {
                throw new SeaTunnelEngineException(
                        String.format(
                                "Could not find any factories that implement '%s' in the classpath.",
                                factoryClass.getName()));
            }

            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",

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Identify the offending factory jar by enabling the underlying cause (log at debug or temporarily catch InvocationTargetException to print its target exception) and remove/upgrade that plugin jar.
  2. Ensure the plugin jar version matches your SeaTunnel engine version so the factory interface and its factoryIdentifier method align.
  3. Rebuild any custom factory so it properly implements the current SeaTunnelFactory interface with a public factoryIdentifier() method.
  4. Clean the plugins directory of duplicate or stale jars and reinstall connectors with install-plugin.sh.

Example fix

// before: custom factory missing the interface method
class MySourceFactory { public String id() { return "MySource"; } }
// after
public class MySourceFactory implements SeaTunnelSourceFactory {
    @Override
    public String factoryIdentifier() { return "MySource"; }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// verify jar integrity: jar tf connector.jar must list META-INF/services factory entries and the factory class

Type guard

boolean isUsableFactory(Object t) { try { t.getClass().getMethod("factoryIdentifier"); return true; } catch (NoSuchMethodException e) { return false; } }

Try / catch

try { FactoryUtil.discoverFactory(FactoryClass.class, classLoader, id); } catch (SeaTunnelEngineException e) { log.error("factory discovery failed, check plugin jars on classpath", e); throw e; }

Prevention

When it happens

Trigger: Calling FactoryUtil.discoverFactory(factoryClass, classLoader, identifier) when a plugin jar on the classpath contains a factory class missing the public factoryIdentifier() method, or whose factoryIdentifier() implementation itself throws (InvocationTargetException).

Common situations: A corrupted/mismatched plugin jar version where the factory interface changed; a custom factory implementing the wrong interface version; shaded jars with conflicting factory classes.

Related errors


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