apache/beam · error · RuntimeException

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

Error message

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

What it means

AutoValueUtils wraps a failure to reflectively instantiate an AutoValue builder (or generate its ByteBuddy creator) into a RuntimeException. When the builder class cannot be constructed via its no-arg declared constructor, Beam cannot map rows to the AutoValue type and aborts. This is almost always a class-loading or compilation issue with the generated builder class.

Source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/AutoValueUtils.java:306

      DynamicType.Builder<SchemaUserTypeCreator> builder =
          BYTE_BUDDY
              .with(new InjectPackageStrategy(builderClass))
              .subclass(SchemaUserTypeCreator.class)
              .method(ElementMatchers.named("create"))
              .intercept(
                  new BuilderCreateInstruction(types, setterMethods, builderClass, buildMethod));
      return builder
          .visit(new ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))
          .make()
          .load(ReflectHelpers.findClassLoader(), getClassLoadingStrategy(builderClass))
          .getLoaded()
          .getDeclaredConstructor()
          .newInstance();
    } catch (InstantiationException
        | IllegalAccessException
        | NoSuchMethodException
        | InvocationTargetException e) {
      throw new RuntimeException(
          "Unable to generate a creator for class " + builderClass + " with schema " + schema);
    }
  }

  static class BuilderCreateInstruction implements Implementation {
    private final List<FieldValueTypeInformation> setters;
    private final Class<?> builderClass;
    private final Method buildMethod;

    BuilderCreateInstruction(
        List<FieldValueTypeInformation> types,
        List<FieldValueTypeInformation> setters,
        Class<?> builderClass,
        Method buildMethod) {
      this.setters = setters;
      this.builderClass = builderClass;
      this.buildMethod = buildMethod;
    }

View on GitHub (pinned to 12126d8942)

Solutions

  1. Verify AutoValue annotation processing is enabled and the Builder class is generated (rebuild the project, check for compile errors from AutoValue).
  2. Ensure the Builder has an accessible no-arg constructor; AutoValue Builders normally do — remove any constructor that breaks instantiation.
  3. Check that the builder constructor body doesn't throw (any exception during newInstance is wrapped here).
  4. Confirm the same class version exists on all workers (use --filesToStage or shaded jar) so reflection doesn't fail remotely.

Example fix

// before: class compiled without annotation processing
// MyAutoValue.Builder.class not generated -> reflection fails
// after: enable annotation processor in build
maven-compiler-plugin: <annotationProcessorPaths><path>com.google.auto.value:auto-value</path></annotationProcessorPaths>
Defensive patterns

Strategy: try-catch

Validate before calling

try { Class.forName("com.example.MyAutoValue$Builder").getDeclaredConstructor().newInstance(); } catch (Throwable t) { /* builder not generatable */ }

Try / catch

try { creator = AutoValueUtils.getBuilderCreator(cls, schema); } catch (RuntimeException e) { /* rebuild with annotation processing / log builderClass */ }

Prevention

When it happens

Trigger: Calling getBuilderCreator for an AutoValue class whose Builder cannot be instantiated with getDeclaredConstructor().newInstance() — e.g. the Builder class exists but throws in a static initializer or constructor, has no accessible no-arg constructor, or fails to load at runtime.

Common situations: AutoValue-generated code is missing or stale (annotation processing didn't run or ran against an older schema); the builder constructor throws (validation in constructor); running on a classpath where the generated classes weren't shaded/relocated correctly; serialized pipeline references a class absent on workers.

Related errors


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