apache/flink · critical · RuntimeException
Cannot create Hadoop WritableTypeInfo.
Error message
Cannot create Hadoop WritableTypeInfo.
What it means
Thrown by TypeExtractor.createHadoopWritableTypeInfo when invoking the HadoopWritableTypeInfo constructor throws an InvocationTargetException — meaning the constructor itself was found and accessible but threw an exception during instantiation. This wraps the target exception from the constructor.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/TypeExtractor.java:2477
Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(
"Could not load the TypeInformation for the class '"
+ HADOOP_WRITABLE_CLASS
+ "'. You may be missing the 'flink-hadoop-compatibility' dependency.");
}
try {
Constructor<?> constr = typeInfoClass.getConstructor(Class.class);
@SuppressWarnings("unchecked")
TypeInformation<T> typeInfo = (TypeInformation<T>) constr.newInstance(clazz);
return typeInfo;
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException e) {
throw new RuntimeException(
"Incompatible versions of the Hadoop Compatibility classes found.");
} catch (InvocationTargetException e) {
throw new RuntimeException(
"Cannot create Hadoop WritableTypeInfo.", e.getTargetException());
}
}
// visible for testing
static void validateIfWritable(TypeInformation<?> typeInfo, Type type) {
try {
// try to load the writable type info
Class<?> writableTypeInfoClass =
Class.forName(
HADOOP_WRITABLE_TYPEINFO_CLASS,
false,
typeInfo.getClass().getClassLoader());
if (writableTypeInfoClass.isAssignableFrom(typeInfo.getClass())) {
// this is actually a writable type info
// check if the type is a writableView on GitHub (pinned to 2f3c205e92)
Solutions
- Inspect the wrapped target exception (e.getCause() or e.getTargetException()) for the root cause.
- Ensure the Writable class has a public no-arg constructor as required by Hadoop Writable contract.
- Verify the class is a concrete class (not abstract or interface) implementing org.apache.hadoop.io.Writable.
- Check for security manager or classloader restrictions that might block reflective instantiation.
Example fix
// before
public class MyWritable implements Writable {
// missing no-arg constructor, has only MyWritable(String s)
}
// after
public class MyWritable implements Writable {
public MyWritable() {} // required no-arg constructor
public MyWritable(String s) { ... }
public void write(DataOutput out) { ... }
public void readFields(DataInput in) { ... }
} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the Writable class has a no-arg constructor before type extraction
try {
myWritableClass.getConstructor();
// OK
} catch (NoSuchMethodException e) {
// Writable class missing no-arg constructor; fix the class
} Type guard
static boolean hasValidWritableConstructor(Class<?> clazz) {
try {
clazz.getConstructor();
return true;
} catch (NoSuchMethodException e) {
return false;
}
} Try / catch
try {
TypeInformation<?> ti = TypeExtractor.createHadoopWritableTypeInfo(MyWritable.class);
} catch (RuntimeException e) {
if (e.getCause() != null) {
// inspect e.getCause() for the constructor's target exception
}
} Prevention
- Ensure Writable classes have a public no-arg constructor.
- Make Writable classes concrete (not abstract).
- Check for security manager restrictions on reflective instantiation.
When it happens
Trigger: Called during createHadoopWritableTypeInfo after constructor lookup succeeds, but constr.newInstance(clazz) throws InvocationTargetException. The HadoopWritableTypeInfo constructor threw an exception, possibly because the passed Writable class is invalid, has security restrictions, or failed internal validation.
Common situations: Passing a class to createHadoopWritableTypeInfo that does not properly implement Hadoop's Writable interface. Security manager restrictions preventing instantiation. Constructor internal validation rejecting the class (e.g., missing no-arg constructor on the Writable type, or the class is abstract).
Related errors
- InputSplit must implement Writable interface.
- Cannot create Comparator for {typeClass.getCanonicalName()}.
- The given class is no subclass of {Writable.class.getName()}
- Could not load the TypeInformation for the class '{}'. You m
- Incompatible versions of the Hadoop Compatibility classes fo
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/7da8b3e6013dca1d.
Report an issue: GitHub.