{"record":{"id":"aa815f25ece6c53b","repo":"apache/flink","slug":"unable-to-instantiate-the-hadoop-output-format-aa815f","errorCode":null,"errorMessage":"Unable to instantiate the hadoop output format","messagePattern":"Unable to instantiate the hadoop output format","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java","lineNumber":274,"sourceCode":"\n        org.apache.hadoop.conf.Configuration configuration =\n                new org.apache.hadoop.conf.Configuration();\n        configuration.readFields(in);\n\n        if (this.configuration == null) {\n            this.configuration = configuration;\n        }\n\n        try {\n            this.mapreduceOutputFormat =\n                    (org.apache.hadoop.mapreduce.OutputFormat<K, V>)\n                            Class.forName(\n                                            hadoopOutputFormatClassName,\n                                            true,\n                                            Thread.currentThread().getContextClassLoader())\n                                    .newInstance();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to instantiate the hadoop output format\", e);\n        }\n    }\n}\n","sourceCodeStart":256,"sourceCodeEnd":278,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java#L256-L278","documentation":"Thrown during Java deserialization of HadoopOutputFormatBase to a TaskManager. readObject() rebuilds the wrapped OutputFormat by name via Class.forName(className, true, contextClassLoader).newInstance(). If the class is missing, abstract, non-instantiable, or lacks an accessible no-arg constructor, the RuntimeException aborts deserialization and the task cannot start.","triggerScenarios":"Triggered on the TaskManager when the serialized HadoopOutputFormat is rebuilt and Class.forName(hadoopOutputFormatClassName, true, contextClassLoader).newInstance() fails — e.g. the OutputFormat class is not in the shipped user jar, has no public no-arg constructor, is abstract, or the context classloader cannot resolve it.","commonSituations":"The Hadoop OutputFormat implementation is not packaged into the submitted user-code jar; class relocated/shaded so the runtime name differs; Hadoop version on the cluster removed/renamed the class; access rules or module boundaries block reflective instantiation.","solutions":["Package the concrete Hadoop OutputFormat class (and dependencies) into the user-code jar submitted with the job.","Confirm the OutputFormat class has a public no-arg constructor required by newInstance().","Verify the cluster Hadoop version exposes the same class name as at build time.","If shading, keep the OutputFormat class name resolvable at runtime (consistent with the serialized name)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before submitting, confirm the OutputFormat class is loadable + instantiable on the cluster\nString className = myOutputFormat.getClass().getName();\ntry {\n    Class<?> c = Class.forName(className, true, Thread.currentThread().getContextClassLoader());\n    if (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) || c.isInterface())\n        throw new IllegalStateException(className + \" is abstract/interface — cannot instantiate\");\n    c.getDeclaredConstructor().newInstance();\n} catch (Exception e) {\n    throw new IllegalStateException(\"OutputFormat class \" + className\n        + \" cannot be instantiated on the cluster (missing jar / no public no-arg ctor)\", e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build a fat user-code jar containing the OutputFormat and dependencies.","Ensure the OutputFormat has a public no-arg constructor.","Keep class names consistent under any shading.","Match Hadoop versions between build and cluster."],"tags":["hadoop","mapreduce","serialization","classloader","output-format"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}