apache/flink · critical · RuntimeException
Unable to instantiate the hadoop output format
Error message
Unable to instantiate the hadoop output format
What it means
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.
Source
Thrown at flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java:274
org.apache.hadoop.conf.Configuration configuration =
new org.apache.hadoop.conf.Configuration();
configuration.readFields(in);
if (this.configuration == null) {
this.configuration = configuration;
}
try {
this.mapreduceOutputFormat =
(org.apache.hadoop.mapreduce.OutputFormat<K, V>)
Class.forName(
hadoopOutputFormatClassName,
true,
Thread.currentThread().getContextClassLoader())
.newInstance();
} catch (Exception e) {
throw new RuntimeException("Unable to instantiate the hadoop output format", e);
}
}
}
View on GitHub (pinned to 2f3c205e92)
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).
Defensive patterns
Strategy: validation
Validate before calling
// Before submitting, confirm the OutputFormat class is loadable + instantiable on the cluster
String className = myOutputFormat.getClass().getName();
try {
Class<?> c = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
if (java.lang.reflect.Modifier.isAbstract(c.getModifiers()) || c.isInterface())
throw new IllegalStateException(className + " is abstract/interface — cannot instantiate");
c.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new IllegalStateException("OutputFormat class " + className
+ " cannot be instantiated on the cluster (missing jar / no public no-arg ctor)", e);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Unable to instantiate the hadoop input format
- Unable to find key class.
- Unable to find value class.
- Unable to instantiate the Hadoop InputSplit
- Unable to instantiate Hadoop InputSplit
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/aa815f25ece6c53b.
Report an issue: GitHub.