{"record":{"id":"3d71ba6dd635f872","repo":"apache/flink","slug":"could-not-find-required-avro-dependency","errorCode":null,"errorMessage":"Could not find required Avro dependency.","messagePattern":"Could not find required Avro dependency\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java","lineNumber":167,"sourceCode":"\n    /**\n     * This is used in case we don't have Avro on the classpath. Flink versions before 1.4 always\n     * registered special Serializers for Kryo but starting with Flink 1.4 we don't have Avro on the\n     * classpath by default anymore. We still have to retain the same registered Serializers for\n     * backwards compatibility of savepoints.\n     */\n    public static class DummyAvroRegisteredClass {}\n\n    /**\n     * This is used in case we don't have Avro on the classpath. Flink versions before 1.4 always\n     * registered special Serializers for Kryo but starting with Flink 1.4 we don't have Avro on the\n     * classpath by default anymore. We still have to retain the same registered Serializers for\n     * backwards compatibility of savepoints.\n     */\n    public static class DummyAvroKryoSerializerClass<T> extends Serializer<T> {\n        @Override\n        public void write(Kryo kryo, Output output, Object o) {\n            throw new UnsupportedOperationException(\"Could not find required Avro dependency.\");\n        }\n\n        @Override\n        public T read(Kryo kryo, Input input, Class<? extends T> aClass) {\n            throw new UnsupportedOperationException(\"Could not find required Avro dependency.\");\n        }\n    }\n}\n","sourceCodeStart":149,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/kryo/Serializers.java#L149-L176","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (pom.xml has no avro dependency; Kryo falls back to dummy)\nDataStream<MyRecord> s = env.fromElements(record);\n\n// after (pom.xml)\n<dependency>\n  <groupId>org.apache.flink</groupId>\n  <artifactId>flink-avro</artifactId>\n  <version>${flink.version}</version>\n</dependency>","handlingStrategy":"validation","validationCode":"static boolean avroAvailable() {\n    try {\n        Class.forName(\"org.apache.avro.specific.SpecificRecordBase\");\n        return true;\n    } catch (ClassNotFoundException e) {\n        return false;\n    }\n}\n// if (!avroAvailable()) fail fast with a clear 'add flink-avro' message","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["kryo","avro","missing-dependency","flink-core"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}