{"record":{"id":"34f3e4f860943918","repo":"apache/flink","slug":"unable-to-instantiate-the-hadoop-input-format","errorCode":null,"errorMessage":"Unable to instantiate the hadoop input format","messagePattern":"Unable to instantiate the hadoop input 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/HadoopInputFormatBase.java","lineNumber":299,"sourceCode":"        super.read(in);\n\n        String hadoopInputFormatClassName = in.readUTF();\n        String keyClassName = in.readUTF();\n        String valueClassName = in.readUTF();\n        if (jobConf == null) {\n            jobConf = new JobConf();\n        }\n        jobConf.readFields(in);\n        try {\n            this.mapredInputFormat =\n                    (org.apache.hadoop.mapred.InputFormat<K, V>)\n                            Class.forName(\n                                            hadoopInputFormatClassName,\n                                            true,\n                                            Thread.currentThread().getContextClassLoader())\n                                    .newInstance();\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to instantiate the hadoop input format\", e);\n        }\n        try {\n            this.keyClass =\n                    (Class<K>)\n                            Class.forName(\n                                    keyClassName,\n                                    true,\n                                    Thread.currentThread().getContextClassLoader());\n        } catch (Exception e) {\n            throw new RuntimeException(\"Unable to find key class.\", e);\n        }\n        try {\n            this.valueClass =\n                    (Class<V>)\n                            Class.forName(\n                                    valueClassName,\n                                    true,\n                                    Thread.currentThread().getContextClassLoader());","sourceCodeStart":281,"sourceCodeEnd":317,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopInputFormatBase.java#L281-L317","documentation":"Thrown by HadoopInputFormatBase.readFields (open/configure phase) when Class.forName(hadoopInputFormatClassName).newInstance() fails. The Hadoop InputFormat class name is read from serialized job configuration; if the class cannot be found, is abstract, lacks a no-arg constructor, or throws in its constructor, this RuntimeException wraps the underlying cause.","triggerScenarios":"Deserializing a HadoopInputFormat whose hadoopInputFormatClassName is not on the task classpath, or whose class cannot be instantiated (abstract, interface, private constructor, or constructor exception).","commonSituations":"Missing Hadoop InputFormat JAR in the Flink job classpath; typo in the class name configured via HadoopInputFormat; version mismatch where the InputFormat class was renamed or removed between Hadoop versions; the InputFormat constructor throws due to missing native libraries.","solutions":["Add the JAR containing the Hadoop InputFormat class to the Flink job classpath (via -C / lib folder / fat JAR).","Verify the class name passed to HadoopInputFormat is the fully qualified name of a concrete, instantiable class.","Inspect the wrapped exception (getCause()) for the root ClassNotFoundException, InstantiationException, or IllegalAccessException.","Ensure the Hadoop version on the classpath matches the version the InputFormat was compiled against."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Validate the InputFormat class is loadable before submitting the job\nString className = hadoopInputFormatClass.getName();\ntry {\n    Class<?> clazz = Class.forName(className);\n    if (clazz.isInterface() || java.lang.reflect.Modifier.isAbstract(clazz.getModifiers())) {\n        throw new IllegalArgumentException(\"InputFormat class must be concrete: \" + className);\n    }\n    clazz.getDeclaredConstructor().newInstance(); // test instantiation\n} catch (Exception e) {\n    throw new IllegalArgumentException(\"Cannot instantiate InputFormat: \" + className, e);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include all Hadoop InputFormat JARs in the Flink job classpath.","Use fully qualified class names for the InputFormat configuration.","Test InputFormat instantiation locally before submitting to the cluster."],"tags":["hadoop-compatibility","input-format","classpath","class-loading"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}