apache/flink · error · UnsupportedOperationException
Could not find required Avro dependency.
Error message
Could not find required Avro dependency.
What it means
Serializers.DummyAvroKryoSerializerClass is a placeholder Kryo serializer registered for Avro types purely to keep savepoint registration IDs identical to pre-1.4 Flink, where flink-core shipped Avro serializers. Since Avro is no longer on flink-core's classpath, the dummy's write() always throws UnsupportedOperationException 'Could not find required Avro dependency.' — hitting it means a write actually tried to serialize an Avro object through the dummy.
Source
Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java:167
/**
* This is used in case we don't have Avro on the classpath. Flink versions before 1.4 always
* registered special Serializers for Kryo but starting with Flink 1.4 we don't have Avro on the
* classpath by default anymore. We still have to retain the same registered Serializers for
* backwards compatibility of savepoints.
*/
public static class DummyAvroRegisteredClass {}
/**
* This is used in case we don't have Avro on the classpath. Flink versions before 1.4 always
* registered special Serializers for Kryo but starting with Flink 1.4 we don't have Avro on the
* classpath by default anymore. We still have to retain the same registered Serializers for
* backwards compatibility of savepoints.
*/
public static class DummyAvroKryoSerializerClass<T> extends Serializer<T> {
@Override
public void write(Kryo kryo, Output output, Object o) {
throw new UnsupportedOperationException("Could not find required Avro dependency.");
}
@Override
public T read(Kryo kryo, Input input, Class<? extends T> aClass) {
throw new UnsupportedOperationException("Could not find required Avro dependency.");
}
}
}
View on GitHub (pinned to 2f3c205e92)
Solutions
- Add flink-avro (and the matching Avro version) to the job's dependencies so real Avro serializers replace the dummy.
- Explicitly register Avro classes/serializers: Serializers.registerAvroSerializers(env) or env.registerTypeWithKryoSerializer(MyAvroRecord.class, AvroSerializer).
- Better: use AvroTypeInfo (SpecificRecord base class) instead of generic Kryo serialization for Avro types.
Example fix
// before (pom.xml has no avro dependency; Kryo falls back to dummy)
DataStream<MyRecord> s = env.fromElements(record);
// after (pom.xml)
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-avro</artifactId>
<version>${flink.version}</version>
</dependency> Defensive patterns
Strategy: validation
Validate before calling
static boolean avroAvailable() {
try {
Class.forName("org.apache.avro.specific.SpecificRecordBase");
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
// if (!avroAvailable()) fail fast with a clear 'add flink-avro' message Prevention
- Add flink-avro to the job pom whenever data types include Avro records.
- Fail fast at job startup (Class.forName check) instead of first record at runtime.
- Use AvroTypeInfo rather than generic Kryo serialization for Avro types.
When it happens
Trigger: Serializing an Avro record (org.apache.avro.specific.*) via Kryo in a job that does NOT include flink-avro (or avro dependency) in the user jar; restoring legacy state whose Kryo registration maps Avro classes to the dummy; relying on default Kryo fallback for Avro types instead of registering flink-avro's serializers.
Common situations: Migrating a pre-1.4 job that serialized Avro objects with Kryo; forgetting to add flink-avro / avro to the pom causing the dummy registration to be used at runtime.
Related errors
- Could not load class 'org.apache.flink.formats.avro.utils.Av
- Could not load the AvroSerializer class. You may be missing
- Could not load the AvroTypeInfo class. You may be missing th
- Error during Java serialization.
- Error during Java deserialization.
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/3d71ba6dd635f872.
Report an issue: GitHub.