apache/flink · error · RuntimeException

Could not load the AvroTypeInfo class. You may be missing th

Error message

Could not load the AvroTypeInfo class. You may be missing the 'flink-avro' dependency.

What it means

Thrown by DefaultAvroUtils.createAvroTypeInfo() when TypeExtractor needs AvroTypeInfo for an Avro record class but flink-avro is absent. AvroTypeInfo is defined in flink-avro and provides Avro-specific schema-aware type information; the no-Avro fallback cannot fabricate it and fails loudly.

Source

Thrown at flink-core/src/main/java/org/apache/flink/api/java/typeutils/AvroUtils.java:151

        public void addAvroGenericDataArrayRegistration(
                LinkedHashMap<String, KryoRegistration> kryoRegistrations) {
            kryoRegistrations.put(
                    AVRO_GENERIC_DATA_ARRAY,
                    new KryoRegistration(
                            Serializers.DummyAvroRegisteredClass.class,
                            (Class) Serializers.DummyAvroKryoSerializerClass.class));
        }

        @Override
        public <T> TypeSerializer<T> createAvroSerializer(Class<T> type) {
            throw new RuntimeException(
                    "Could not load the AvroSerializer class. "
                            + "You may be missing the 'flink-avro' dependency.");
        }

        @Override
        public <T> TypeInformation<T> createAvroTypeInfo(Class<T> type) {
            throw new RuntimeException(
                    "Could not load the AvroTypeInfo class. "
                            + "You may be missing the 'flink-avro' dependency.");
        }
    }
}

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Add flink-avro dependency (provided scope when cluster provides it).
  2. Verify the Avro record class actually needs AvroTypeInfo; if so the jar is mandatory.
  3. Eliminate the Avro type if you cannot add the dependency by mapping to a POJO/tuple.

Example fix

// before
DataStream<MyAvroRecord> out = in.map(x -> toAvro(x)); // type info needs flink-avro

// after: add dependency so AvroTypeInfo resolves
<dependency>
  <groupId>org.apache.flink</groupId><artifactId>flink-avro</artifactId><version>${flink.version}</version><scope>provided</scope>
</dependency>
Defensive patterns

Strategy: validation

Validate before calling

if (!AvroUtils.tryGetAvroUtils().isPresent() && isAvroRecordClass(myClass)) {
    throw new IllegalStateException("flink-avro missing; cannot create AvroTypeInfo");
}

Prevention

When it happens

Trigger: TypeExtractor determines a class is an Avro record and routes to createAvroTypeInfo(); DefaultAvroUtils throws because flink-avro is missing.

Common situations: Returning an Avro record from a function whose return type is inferred; registering an Avro POJO for type extraction; a UDF whose output type is Avro.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/19261d1c7125fd14. Report an issue: GitHub.