{"record":{"id":"8d908d9fcc6f76e9","repo":"apache/incubator-seata","slug":"not-found-service-provider-for-caused-by","errorCode":null,"errorMessage":"not found service provider for : {} caused by {}","messagePattern":"not found service provider for : (.+?) caused by (.+?)","errorType":"exception","errorClass":"EnhancedServiceNotFoundException","httpStatus":null,"severity":"error","filePath":"common/src/main/java/org/apache/seata/common/loader/EnhancedServiceLoader.java","lineNumber":443,"sourceCode":"        /**\n         * Get all the extension classes, follow {@linkplain LoadLevel} defined and sort order\n         *\n         * @param loader the loader\n         * @return all extension class\n         */\n        private List<Class<S>> getAllExtensionClass(ClassLoader loader, boolean includeCompatible) {\n            return loadAllExtensionClass(loader, includeCompatible);\n        }\n\n        private S loadExtension(ClassLoader loader, Class<?>[] argTypes, Object[] args, boolean includeCompatible) {\n            try {\n                loadAllExtensionClass(loader, includeCompatible);\n                ExtensionDefinition<S> defaultExtensionDefinition = getDefaultExtensionDefinition();\n                return getExtensionInstance(defaultExtensionDefinition, loader, argTypes, args);\n            } catch (EnhancedServiceNotFoundException e) {\n                throw e;\n            } catch (Throwable e) {\n                throw new EnhancedServiceNotFoundException(\"not found service provider for : \" + type.getName()\n                        + \" caused by \" + ExceptionUtils.getStackTrace(e));\n            }\n        }\n\n        @SuppressWarnings(\"rawtypes\")\n        private S loadExtension(\n                String activateName, ClassLoader loader, Class[] argTypes, Object[] args, boolean includeCompatible) {\n            if (StringUtils.isEmpty(activateName)) {\n                throw new IllegalArgumentException(\n                        \"the name of service provider for [\" + type.getName() + \"] name is null\");\n            }\n            try {\n                loadAllExtensionClass(loader, includeCompatible);\n                ExtensionDefinition<S> cachedExtensionDefinition = getCachedExtensionDefinition(activateName);\n                return getExtensionInstance(cachedExtensionDefinition, loader, argTypes, args);\n            } catch (Throwable e) {\n                if (e instanceof EnhancedServiceNotFoundException) {\n                    throw (EnhancedServiceNotFoundException) e;","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/common/src/main/java/org/apache/seata/common/loader/EnhancedServiceLoader.java#L425-L461","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the embedded 'caused by' stack trace — the root cause names the actual failing class and line.","Fix the provider's constructor/static initializer (e.g. lazy-connect instead of connecting in the constructor).","Add the transitive dependencies the provider needs at runtime.","If the provider is optional, de-register it from META-INF/services instead of letting it fail."],"exampleFix":"// before: provider constructor does eager IO\npublic MyConfigProvider() { this.store = Files.readString(Path.of(\"cfg.json\")); }\n\n// after: defer IO until first use\npublic MyConfigProvider() { }\nprivate String load() { return Files.readString(Path.of(\"cfg.json\")); }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    T provider = EnhancedServiceLoader.load(SpiType.class);\n} catch (EnhancedServiceNotFoundException e) {\n    // 'caused by' section holds the real stack trace of the instantiation failure\n    String msg = e.getMessage();\n    if (msg.contains(\"caused by\")) {\n        // provider WAS found but failed to construct: fix provider ctor, do not just add jars\n    } else {\n        // provider genuinely absent: add the module containing the SPI implementation\n    }\n    throw e;\n}","preventionTips":["Keep SPI provider constructors side-effect-free; connect lazily.","Unit-test custom providers via EnhancedServiceLoader.load in CI so construction failures surface at build time.","Provide clear no-arg constructors matching how the loader instantiates providers."],"tags":["spi","service-loader","provider","initialization","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}