apache/beam · error · RuntimeException

Could not instantiate deserializers

Error message

Could not instantiate deserializers

What it means

LocalDeserializerProvider.getDeserializer reflectively instantiates the configured Deserializer class per consumer. If instantiation or configure() fails (no no-arg constructor, abstract class, access or config errors — InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException), the multi-catch is rethrown as RuntimeException 'Could not instantiate deserializers'.

Solutions

  1. Ensure the deserializer class is public, concrete, and has a public no-arg constructor.
  2. Confirm the class is on the runtime classpath (no ClassNotFoundException).
  3. Inspect the wrapped cause for the failure from configure(configs, isKey).
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/LocalDeserializerProvider.java:59 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/271d0a4c1404c6ab. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/LocalDeserializerProvider.java:59

    checkArgument(deserializer != null, "You should provide a deserializer.");
    this.deserializer = deserializer;
  }

  static <T> LocalDeserializerProvider<T> of(Class<? extends Deserializer<T>> deserializer) {
    return new LocalDeserializerProvider<>(deserializer);
  }

  @Override
  public Deserializer<T> getDeserializer(Map<String, ?> configs, boolean isKey) {
    try {
      Deserializer<T> deserializer = this.deserializer.getDeclaredConstructor().newInstance();
      deserializer.configure(configs, isKey);
      return deserializer;
    } catch (InstantiationException
        | IllegalAccessException
        | InvocationTargetException
        | NoSuchMethodException e) {
      throw new RuntimeException("Could not instantiate deserializers", e);
    }
  }

  /**
   * Attempt to infer a {@link Coder} by extracting the type of the deserialized-class from the
   * deserializer argument using the {@link Coder} registry.
   */
  @Override
  public Coder<T> getCoder(CoderRegistry coderRegistry) {
    // It is safe to treat a Coder<@Nullable T> as a Coder<T> for deserialization
    // purposes
    return (Coder<T>) getNullableCoder(coderRegistry);
  }

  public NullableCoder<T> getNullableCoder(CoderRegistry coderRegistry) {
    for (Type type : deserializer.getGenericInterfaces()) {
      if (!(type instanceof ParameterizedType)) {
        continue;

View on GitHub (pinned to 12126d8942)