{"record":{"id":"606da5c8068249e6","repo":"apache/flink","slug":"no-clusterclientfactory-found-if-you-were-targeti","errorCode":null,"errorMessage":"No ClusterClientFactory found. If you were targeting a Yarn cluster, please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your classpath. For more information refer to the \"Deployment\" section of the official Apache Flink documentation.","messagePattern":"No ClusterClientFactory found\\. If you were targeting a Yarn cluster, please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your classpath\\. For more information refer to the \"Deployment\" section of the official Apache Flink documentation\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java","lineNumber":90,"sourceCode":"                    throw e;\n                }\n            }\n        }\n\n        if (compatibleFactories.size() > 1) {\n            final List<String> configStr =\n                    configuration.toMap().entrySet().stream()\n                            .map(e -> e.getKey() + \"=\" + e.getValue())\n                            .collect(Collectors.toList());\n\n            throw new IllegalStateException(\n                    \"Multiple compatible client factories found for:\\n\"\n                            + String.join(\"\\n\", configStr)\n                            + \".\");\n        }\n\n        if (compatibleFactories.isEmpty()) {\n            throw new IllegalStateException(\n                    \"No ClusterClientFactory found. If you were targeting a Yarn cluster, \"\n                            + \"please make sure to export the HADOOP_CLASSPATH environment variable or have hadoop in your \"\n                            + \"classpath. For more information refer to the \\\"Deployment\\\" section of the official \"\n                            + \"Apache Flink documentation.\");\n        }\n\n        return (ClusterClientFactory<ClusterID>) compatibleFactories.get(0);\n    }\n\n    @Override\n    public Stream<String> getApplicationModeTargetNames() {\n        final ServiceLoader<ClusterClientFactory> loader =\n                ServiceLoader.load(ClusterClientFactory.class);\n\n        final List<String> result = new ArrayList<>();\n\n        final Iterator<ClusterClientFactory> it = loader.iterator();\n        while (true) {","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-clients/src/main/java/org/apache/flink/client/deployment/DefaultClusterClientServiceLoader.java#L72-L108","documentation":"Thrown by DefaultClusterClientServiceLoader.getClusterClientFactory when no ClusterClientFactory implementation reports isCompatible(configuration) as true. Flink discovers all factories via Java ServiceLoader; if none match, it cannot determine the deployment target. The error specifically mentions HADOOP_CLASSPATH because the most common cause is YARN deployment without Hadoop libraries on the classpath, which prevents the YARN factory from loading.","triggerScenarios":"Targeting YARN but HADOOP_CLASSPATH is not set (no Hadoop JARs available to the YarnClusterClientFactory); targeting a deployment type whose factory JAR is not on the classpath; an empty or minimal classpath that excludes all connector distributions; execution.target not set and no factory's default heuristic matches.","commonSituations":"Fresh Flink installation without Hadoop configured; running in an environment where Hadoop configs (core-site.xml, yarn-site.xml) are missing; container image that bundles Flink but not Hadoop; targeting Kubernetes but flink-kubernetes JAR is excluded.","solutions":["For YARN: export HADOOP_CLASSPATH=`hadoop classpath` and ensure Hadoop is installed","Set -Dexecution.target=<yarn|kubernetes-session|kubernetes-application|remote> explicitly","Verify the relevant connector JAR (flink-yarn, flink-kubernetes) is in FLINK_HOME/lib/","Ensure Hadoop config files (core-site.xml, yarn-site.xml) are on the classpath or in HADOOP_CONF_DIR"],"exampleFix":"# before (no Hadoop on classpath)\nflink run -m yarn ./job.jar\n\n# after\nexport HADOOP_CLASSPATH=`hadoop classpath`\nflink run -m yarn ./job.jar","handlingStrategy":"validation","validationCode":"// For YARN: verify Hadoop is on the classpath before submitting:\nif (config.get(DeploymentOptions.TARGET).contains(\"yarn\")) {\n    String hadoopCp = System.getenv(\"HADOOP_CLASSPATH\");\n    if (hadoopCp == null || hadoopCp.isBlank()) {\n        throw new IllegalStateException(\n            \"HADOOP_CLASSPATH not set. Run: export HADOOP_CLASSPATH=`hadoop classpath`\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ClusterClientFactory<?> factory = serviceLoader.getClusterClientFactory(config);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"No ClusterClientFactory\")) {\n        System.err.println(\"No factory found. Check HADOOP_CLASSPATH and connector JARs.\");\n    }\n    throw e;\n}","preventionTips":["For YARN: always run `export HADOOP_CLASSPATH=\\`hadoop classpath\\`` before starting Flink","Verify the relevant connector JAR is in FLINK_HOME/lib/","Set -Dexecution.target=<backend> explicitly to guide factory selection"],"tags":["deployment","service-loader","classpath","configuration"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}