{"record":{"id":"6caba04c6c99b447","repo":"apache/flink","slug":"could-not-load-the-avroserializer-class-you-may-b","errorCode":null,"errorMessage":"Could not load the AvroSerializer class. You may be missing the 'flink-avro' dependency.","messagePattern":"Could not load the AvroSerializer class\\. You may be missing the 'flink-avro' dependency\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java","lineNumber":144,"sourceCode":"                                + \"'. \"\n                                + \"You may be missing the 'flink-avro' dependency.\");\n            }\n        }\n\n        @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n        @Override\n        public void addAvroGenericDataArrayRegistration(\n                LinkedHashMap<String, KryoRegistration> kryoRegistrations) {\n            kryoRegistrations.put(\n                    AVRO_GENERIC_DATA_ARRAY,\n                    new KryoRegistration(\n                            Serializers.DummyAvroRegisteredClass.class,\n                            (Class) Serializers.DummyAvroKryoSerializerClass.class));\n        }\n\n        @Override\n        public <T> TypeSerializer<T> createAvroSerializer(Class<T> type) {\n            throw new RuntimeException(\n                    \"Could not load the AvroSerializer class. \"\n                            + \"You may be missing the 'flink-avro' dependency.\");\n        }\n\n        @Override\n        public <T> TypeInformation<T> createAvroTypeInfo(Class<T> type) {\n            throw new RuntimeException(\n                    \"Could not load the AvroTypeInfo class. \"\n                            + \"You may be missing the 'flink-avro' dependency.\");\n        }\n    }\n}\n","sourceCodeStart":126,"sourceCodeEnd":157,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java#L126-L157","documentation":"Thrown by DefaultAvroUtils.createAvroSerializer() when the type system asks for an AvroSerializer but flink-avro is absent (DefaultAvroUtils is the no-Avro fallback). The real AvroSerializer lives in flink-avro and cannot be loaded, so creating a serializer for an Avro type fails immediately instead of producing a broken Kryo serializer.","triggerScenarios":"createSerializer() on a TypeInformation backed by an Avro type, or explicit AvroSerializer instantiation through AvroUtils when flink-avro is not on the classpath.","commonSituations":"State backend / checkpoint requesting a serializer for a keyed state whose type is an Avro record, but the job was submitted without flink-avro; using Avro POJOs as keys without the format jar.","solutions":["Add flink-avro to the job dependencies (provided scope for cluster deployment).","Confirm the jar is present at runtime in the TaskManager classpath (lib/ or user-jar).","If Avro use is accidental, switch the type to a non-Avro serializable type."],"exampleFix":"// before: keyed state on Avro record, no flink-avro\nListState<MyAvroRecord> st = ctx.getListState(descriptor);\n\n// after: ensure flink-avro is on the classpath, scope provided\nmvn dependency:tree | grep avro  # then add flink-avro provided","handlingStrategy":"validation","validationCode":"boolean canCreateAvroSerializer = AvroUtils.tryGetAvroUtils().isPresent();\nif (!canCreateAvroSerializer) {\n    throw new IllegalStateException(\"flink-avro missing; cannot build AvroSerializer for keyed state\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include flink-avro when Avro records are used as state keys/values.","Use provided scope so the cluster lib/ copy is used.","Smoke-test state registration in a local mini-cluster before deploying."],"tags":["avro","missing-dependency","serializer","state"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}