apache/beam · error · java.lang.RuntimeException

Unable to generate a creator for class

Error message

Unable to generate a creator for class ${builderClass} with schema ${schema}

What it means

ProtoByteBuddyUtils' creator factory builds a SchemaUserTypeCreator that instantiates a proto Builder via its no-arg newInstance. If that reflective instantiation fails (InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), a RuntimeException is thrown naming the builder class and schema. The reflective cause is dropped here.

Solutions

  1. Check e.getCause() in a debugger to find the exact reflective failure
  2. Ensure the builder class is a concrete MessageLite.Builder subclass with an accessible no-arg constructor
  3. Regenerate proto classes; don't pass abstract/manual builder classes to the schema creator
  4. Avoid environments that block reflection/bytecode (e.g. native-image without config)

Example fix

// before
// passing abstract CustomBuilder extends Builder to schema creator
// after
// use MyMessage.Builder (generated, concrete no-arg newBuilder())
Defensive patterns

Strategy: validation

Validate before calling

// ensure builderClass is instantiable via no-arg newInstance before schema build
if (Modifier.isAbstract(builderClass.getModifiers()) || builderClass.isMemberClass()) throw new IllegalStateException("builderClass must be a top-level concrete Builder");

Prevention

When it happens

Trigger: Generating a creator for a proto message schema where builderClass has no accessible no-arg newBuilder()/newInstance-equivalent constructor, or instantiation is blocked by the environment.

Common situations: Abstract or non-standard proto classes passed as the builder type; nested/inner classes with implicit constructor args; restricted JVMs; schema built against a proto class that changed shape.

Related errors


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

Appendix: source

Thrown at sdks/java/extensions/protobuf/src/main/java/org/apache/beam/sdk/extensions/protobuf/ProtoByteBuddyUtils.java:1147

                          .build())
                  .method(ElementMatchers.named("get"))
                  .intercept(new BuilderSupplier(protoClass));
      Supplier<ProtoBuilderT> supplier =
          builder
              .visit(
                  new AsmVisitorWrapper.ForDeclaredMethods()
                      .writerFlags(ClassWriter.COMPUTE_FRAMES))
              .make()
              .load(targetClass.getClassLoader(), getClassLoadingStrategy(targetClass))
              .getLoaded()
              .getDeclaredConstructor()
              .newInstance();
      return new ProtoCreatorFactory<>(supplier, setters);
    } catch (InstantiationException
        | IllegalAccessException
        | NoSuchMethodException
        | InvocationTargetException e) {
      throw new RuntimeException(
          "Unable to generate a creator for class " + builderClass + " with schema " + schema);
    }
  }

  static class ProtoCreatorFactory<ProtoBuilderT extends MessageLite.Builder>
      implements SchemaUserTypeCreator {
    private final Supplier<ProtoBuilderT> builderCreator;
    private final List<FieldValueSetter<ProtoBuilderT, Object>> setters;

    public ProtoCreatorFactory(
        Supplier<ProtoBuilderT> builderCreator,
        List<FieldValueSetter<ProtoBuilderT, Object>> setters) {
      this.builderCreator = builderCreator;
      this.setters = setters;
    }

    @Override
    public Object create(@Nullable Object... params) {

View on GitHub (pinned to 12126d8942)