{"record":{"id":"11679584dbf79b50","repo":"apache/seatunnel","slug":"could-not-load-service-provider-for-factories-116795","errorCode":null,"errorMessage":"Could not load service provider for factories.","messagePattern":"Could not load service provider for factories\\.","errorType":"exception","errorClass":"SeaTunnelEngineException","httpStatus":null,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/utils/FactoryUtil.java","lineNumber":86,"sourceCode":"\n            if (foundFactories.size() > 1) {\n                throw new SeaTunnelEngineException(\n                        String.format(\n                                \"Multiple factories for identifier '%s' that implement '%s' found in the classpath.\\n\\n\"\n                                        + \"Ambiguous factory classes are:\\n\\n\"\n                                        + \"%s\",\n                                factoryIdentifier,\n                                factoryClass.getName(),\n                                foundFactories.stream()\n                                        .map(f -> f.getClass().getName())\n                                        .sorted()\n                                        .collect(Collectors.joining(\"\\n\"))));\n            }\n\n            return foundFactories.get(0);\n        } catch (ServiceConfigurationError e) {\n            log.error(\"Could not load service provider for factories.\", e);\n            throw new SeaTunnelEngineException(\"Could not load service provider for factories.\", e);\n        }\n    }\n}\n","sourceCodeStart":68,"sourceCodeEnd":90,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/utils/FactoryUtil.java#L68-L90","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the logged cause (log.error prints the ServiceConfigurationError) to find which provider class failed and why.","Install the missing dependency jars alongside the connector plugin.","Re-download/reinstall the connector to repair a corrupted jar or truncated META-INF/services entry.","Align SeaTunnel and plugin versions so shaded dependencies (org.apache.seatunnel.shade.*) resolve correctly."],"exampleFix":"// before: plugin dir missing driver jar\nconnectors/connector-jdbc-2.3.8.jar\n// after\nconnectors/connector-jdbc-2.3.8.jar\nconnectors/mysql-connector-java-8.0.29.jar (or driver in $SEATUNNEL_HOME/lib)","handlingStrategy":"try-catch","validationCode":"// pre-check providers loadable\nfor (Class<?> f : ServiceLoader.load(FactoryClass.class, cl)) { /* instantiation happens here; failure surfaces early */ }","typeGuard":null,"tryCatchPattern":"try { FactoryUtil.discoverFactory(f, cl, id); } catch (SeaTunnelEngineException e) { log.error(\"SPI provider failed to load; check missing dependency jars\", e.getCause()); throw e; }","preventionTips":["Install all dependency jars required by each connector (drivers, shaded deps).","Verify jars with 'jar tf' after download to catch truncation.","Keep engine and plugin versions aligned."],"tags":["spi","service-loader","classpath","zeta-engine"],"backgroundTag":"class-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}