apache/flink · error · RuntimeException
Unable to instantiate the hadoop input format
Error message
Unable to instantiate the hadoop input format
What it means
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.
Source
Thrown at flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapred/HadoopInputFormatBase.java:299
super.read(in);
String hadoopInputFormatClassName = in.readUTF();
String keyClassName = in.readUTF();
String valueClassName = in.readUTF();
if (jobConf == null) {
jobConf = new JobConf();
}
jobConf.readFields(in);
try {
this.mapredInputFormat =
(org.apache.hadoop.mapred.InputFormat<K, V>)
Class.forName(
hadoopInputFormatClassName,
true,
Thread.currentThread().getContextClassLoader())
.newInstance();
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate the hadoop input format", e);
}
try {
this.keyClass =
(Class<K>)
Class.forName(
keyClassName,
true,
Thread.currentThread().getContextClassLoader());
} catch (Exception e) {
throw new RuntimeException("Unable to find key class.", e);
}
try {
this.valueClass =
(Class<V>)
Class.forName(
valueClassName,
true,
Thread.currentThread().getContextClassLoader());View on GitHub (pinned to 2f3c205e92)
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.
Defensive patterns
Strategy: validation
Validate before calling
// Validate the InputFormat class is loadable before submitting the job
String className = hadoopInputFormatClass.getName();
try {
Class<?> clazz = Class.forName(className);
if (clazz.isInterface() || java.lang.reflect.Modifier.isAbstract(clazz.getModifiers())) {
throw new IllegalArgumentException("InputFormat class must be concrete: " + className);
}
clazz.getDeclaredConstructor().newInstance(); // test instantiation
} catch (Exception e) {
throw new IllegalArgumentException("Cannot instantiate InputFormat: " + className, e);
} Prevention
- 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.
When it happens
Trigger: Deserializing a HadoopInputFormat whose hadoopInputFormatClassName is not on the task classpath, or whose class cannot be instantiated (abstract, interface, private constructor, or constructor exception).
Common situations: 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.
Related errors
- Unable to find key class.
- Unable to find value class.
- Unable to instantiate the hadoop output format
- The program's entry point class '{className}' could not be l
- Could not load class for serialization config
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/34f3e4f860943918.
Report an issue: GitHub.