{"record":{"id":"efc7eb4752f066a1","repo":"apache/flink","slug":"could-not-load-class-org-apache-flink-formats-avr","errorCode":null,"errorMessage":"Could not load class 'org.apache.flink.formats.avro.utils.AvroKryoSerializerUtils'. You may be missing the 'flink-avro' dependency.","messagePattern":"Could not load class 'org\\.apache\\.flink\\.formats\\.avro\\.utils\\.AvroKryoSerializerUtils'\\. 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":123,"sourceCode":"    public abstract <T> TypeInformation<T> createAvroTypeInfo(Class<T> type);\n\n    // ------------------------------------------------------------------------\n\n    /** A default implementation of the AvroUtils used in the absence of Avro. */\n    private static class DefaultAvroUtils extends AvroUtils {\n\n        private static final String AVRO_GENERIC_RECORD =\n                \"org.apache.avro.generic.GenericData$Record\";\n\n        private static final String AVRO_GENERIC_DATA_ARRAY =\n                \"org.apache.avro.generic.GenericData$Array\";\n\n        @Override\n        public void addAvroSerializersIfRequired(SerializerConfig reg, Class<?> type) {\n            if (hasSuperclass(type, AVRO_SPECIFIC_RECORD_BASE_CLASS)\n                    || hasSuperclass(type, AVRO_GENERIC_RECORD)) {\n\n                throw new RuntimeException(\n                        \"Could not load class '\"\n                                + AVRO_KRYO_UTILS\n                                + \"'. \"\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","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java#L105-L141","documentation":"Thrown by DefaultAvroUtils.addAvroSerializersIfRequired() — the fallback implementation used when flink-avro is NOT on the classpath. When Flink detects a type that is an Avro SpecificRecord or GenericRecord (via superclass match), it needs Avro-aware serializers which only exist in flink-avro. Rather than silently fall back to Kryo (which corrupts Avro), it throws to tell you to add the dependency.","triggerScenarios":"TypeExtractor encounters a class that extends org.apache.avro.specific.SpecificRecordBase or org.apache.avro.generic.GenericData$Record, calls into addAvroSerializersIfRequired, and DefaultAvroUtils (no-Avro fallback) throws because flink-avro is absent.","commonSituations":"Using Avro-generated POJOs or GenericRecord in a job without adding flink-avro; reading Avro-format data without the format jar; a connector bringing in an Avro type transitively but not the Flink Avro integration.","solutions":["Add flink-avro as a dependency (scope provided when deploying to a Flink cluster that has it in lib/, otherwise compile).","If you did not intend to use Avro, find the source of the Avro-typed record in your pipeline and replace it with a plain POJO or tuple.","Ensure the flink-avro jar is actually on the runtime classpath (cluster lib/ dir), not just the build classpath."],"exampleFix":"// before: Avro record used, no flink-avro dependency\nDataStream<MyAvroRecord> s = env.fromSource(avroSource, ...);\n\n// after\n<dependency>\n  <groupId>org.apache.flink</groupId><artifactId>flink-avro</artifactId>\n  <version>${flink.version}</version><scope>provided</scope>\n</dependency>","handlingStrategy":"validation","validationCode":"// Guard before introducing Avro types\nboolean avroAvailable = AvroUtils.tryGetAvroUtils().isPresent();\nif (!avroAvailable && usesAvroRecord(myType)) {\n    throw new IllegalStateException(\"Add flink-avro dependency before using Avro records\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add flink-avro whenever you use SpecificRecord/GenericRecord.","If you do not need Avro, exclude the Avro types from your pipeline.","Verify the jar is present at runtime, not just at compile time."],"tags":["avro","missing-dependency","serializer","type-system"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}