{"record":{"id":"d3d52750e52a1639","repo":"apache/flink","slug":"unable-to-instantiate-the-hadoop-output-format","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":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopOutputFormatBase.java","lineNumber":220,"sourceCode":"\n    @SuppressWarnings(\"unchecked\")\n    private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {\n        super.read(in);\n        String hadoopOutputFormatName = in.readUTF();\n        if (jobConf == null) {\n            jobConf = new JobConf();\n        }\n        jobConf.readFields(in);\n        try {\n            this.mapredOutputFormat =\n                    (org.apache.hadoop.mapred.OutputFormat<K, V>)\n                            Class.forName(\n                                            hadoopOutputFormatName,\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        ReflectionUtils.setConf(mapredOutputFormat, jobConf);\n\n        jobConf.getCredentials().addAll(this.credentials);\n        Credentials currentUserCreds = getCredentialsFromUGI(UserGroupInformation.getCurrentUser());\n        if (currentUserCreds != null) {\n            jobConf.getCredentials().addAll(currentUserCreds);\n        }\n    }\n}\n","sourceCodeStart":202,"sourceCodeEnd":231,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopOutputFormatBase.java#L202-L231","documentation":"Thrown by HadoopOutputFormatBase.readFields (configure phase) when Class.forName(hadoopOutputFormatName).newInstance() fails. The Hadoop OutputFormat class name is read from the serialized JobConf; if the class is absent from the classpath, is abstract, lacks a public no-arg constructor, or throws during construction, this RuntimeException wraps the root cause.","triggerScenarios":"Deserializing a HadoopOutputFormat whose class name is not resolvable on the task classpath, or whose class cannot be instantiated.","commonSituations":"Missing Hadoop OutputFormat JAR in the Flink job classpath; class renamed or removed between Hadoop versions; classloader isolation hiding the OutputFormat class; constructor requiring configuration that is not available.","solutions":["Add the JAR containing the Hadoop OutputFormat class to the Flink job classpath.","Verify the class name is a concrete, instantiable class with a public no-arg constructor.","Inspect getCause() for ClassNotFoundException, InstantiationException, or IllegalAccessException details.","Ensure Hadoop version compatibility between the OutputFormat JAR and the Flink Hadoop compatibility layer."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the OutputFormat class is loadable and instantiable before submitting\nString className = hadoopOutputFormatClass.getName();\ntry {\n    Class<?> clazz = Class.forName(className);\n    if (clazz.isInterface() || java.lang.reflect.Modifier.isAbstract(clazz.getModifiers())) {\n        throw new IllegalArgumentException(\"OutputFormat class must be concrete: \" + className);\n    }\n    clazz.getDeclaredConstructor().newInstance();\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"Cannot instantiate OutputFormat: \" + className, e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include all Hadoop OutputFormat JARs in the Flink job classpath.","Verify the OutputFormat class is concrete with a public no-arg constructor.","Test OutputFormat instantiation locally before cluster deployment."],"tags":["hadoop-compatibility","output-format","classpath","class-loading"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}