apache/incubator-seata · error · EnhancedServiceNotFoundException

not found service provider for : {} caused by {}

Error message

not found service provider for : {} caused by {}

What it means

Inner-class loadExtension(ClassLoader,...) of seata's EnhancedServiceLoader: after loading all extension definitions it instantiates the default extension; any Throwable other than EnhancedServiceNotFoundException (e.g. constructor threw, class init failed, linkage error) is wrapped as EnhancedServiceNotFoundException with 'not found service provider for : <type> caused by <stacktrace>'. The 'caused by' part is the real diagnosis.

Source

Thrown at common/src/main/java/org/apache/seata/common/loader/EnhancedServiceLoader.java:443

        /**
         * Get all the extension classes, follow {@linkplain LoadLevel} defined and sort order
         *
         * @param loader the loader
         * @return all extension class
         */
        private List<Class<S>> getAllExtensionClass(ClassLoader loader, boolean includeCompatible) {
            return loadAllExtensionClass(loader, includeCompatible);
        }

        private S loadExtension(ClassLoader loader, Class<?>[] argTypes, Object[] args, boolean includeCompatible) {
            try {
                loadAllExtensionClass(loader, includeCompatible);
                ExtensionDefinition<S> defaultExtensionDefinition = getDefaultExtensionDefinition();
                return getExtensionInstance(defaultExtensionDefinition, loader, argTypes, args);
            } catch (EnhancedServiceNotFoundException e) {
                throw e;
            } catch (Throwable e) {
                throw new EnhancedServiceNotFoundException("not found service provider for : " + type.getName()
                        + " caused by " + ExceptionUtils.getStackTrace(e));
            }
        }

        @SuppressWarnings("rawtypes")
        private S loadExtension(
                String activateName, ClassLoader loader, Class[] argTypes, Object[] args, boolean includeCompatible) {
            if (StringUtils.isEmpty(activateName)) {
                throw new IllegalArgumentException(
                        "the name of service provider for [" + type.getName() + "] name is null");
            }
            try {
                loadAllExtensionClass(loader, includeCompatible);
                ExtensionDefinition<S> cachedExtensionDefinition = getCachedExtensionDefinition(activateName);
                return getExtensionInstance(cachedExtensionDefinition, loader, argTypes, args);
            } catch (Throwable e) {
                if (e instanceof EnhancedServiceNotFoundException) {
                    throw (EnhancedServiceNotFoundException) e;

View on GitHub (pinned to e01f97c6db)

Solutions

  1. Read the embedded 'caused by' stack trace — the root cause names the actual failing class and line.
  2. Fix the provider's constructor/static initializer (e.g. lazy-connect instead of connecting in the constructor).
  3. Add the transitive dependencies the provider needs at runtime.
  4. If the provider is optional, de-register it from META-INF/services instead of letting it fail.

Example fix

// before: provider constructor does eager IO
public MyConfigProvider() { this.store = Files.readString(Path.of("cfg.json")); }

// after: defer IO until first use
public MyConfigProvider() { }
private String load() { return Files.readString(Path.of("cfg.json")); }
Defensive patterns

Strategy: try-catch

Try / catch

try {
    T provider = EnhancedServiceLoader.load(SpiType.class);
} catch (EnhancedServiceNotFoundException e) {
    // 'caused by' section holds the real stack trace of the instantiation failure
    String msg = e.getMessage();
    if (msg.contains("caused by")) {
        // provider WAS found but failed to construct: fix provider ctor, do not just add jars
    } else {
        // provider genuinely absent: add the module containing the SPI implementation
    }
    throw e;
}

Prevention

When it happens

Trigger: EnhancedServiceLoader.load(SomeSpi.class) (no name) where the default provider exists in META-INF/services but its constructor or static initializer throws, or its dependencies are absent at instantiation time.

Common situations: Registering a custom seata SPI provider (config, registry, serializer) whose constructor connects to an unavailable backend or throws NPE; missing transitive dependencies of the provider; version-mismatched provider implementations.

Related errors


AI-assisted analysis of apache/incubator-seata@e01f97c6db (2026-08-14). Data as JSON: /api/errors/8d908d9fcc6f76e9. Report an issue: GitHub.