apache/beam · error · RuntimeException
Could not find a way to create AutoValue class
Error message
Could not find a way to create AutoValue class <descriptor>
What it means
AutoValueSchema.schemaTypeCreator needs a way to construct instances of the AutoValue class: either a generated Builder or a package-private constructor in the generated AutoValue_Foo class. When getConstructorCreator returns null for both, Beam cannot map rows back into the class and throws this error.
Solutions
- Verify the class is annotated @AutoValue and AutoValue_Foo is generated (check target/generated-sources or build output).
- Clean rebuild to ensure annotation processing ran; enable annotationProcessorPaths in Maven/Gradle if missing.
- Add an explicit @AutoValue.Builder to the class so Beam can use the builder creator path.
- Avoid private/nested or shaded AutoValue classes for schema rows.
Example fix
// before
public abstract class Foo { public abstract String getName(); }
// after
@AutoValue public abstract class Foo {
public abstract String getName();
@AutoValue.Builder public abstract static class Builder {}
} Defensive patterns
Strategy: validation
Validate before calling
if (!targetType.isAnnotationPresent(AutoValue.class)) throw new IllegalStateException(targetType + " is not an @AutoValue class");
Type guard
static boolean hasAutoValueImplementation(Class<?> c) {
try { Class.forName(c.getName() + "$"); return false; } // not an AutoValue shape
catch (ClassNotFoundException e) { }
try { Class.forName(c.getName() + "$Builder"); return true; }
catch (ClassNotFoundException e) { return false; } // relies on ctor path
} Try / catch
try { schema = Schema.of(MyAutoValue.class); }
catch (RuntimeException e) {
if (e.getMessage().contains("Could not find a way to create AutoValue class")) {
throw new IllegalStateException("Ensure @AutoValue processing ran and a Builder or ctor exists", e);
} throw e;
} Prevention
- Annotate row classes with @AutoValue and add @AutoValue.Builder
- Verify annotationProcessorPaths in Maven/Gradle
- Avoid shaded or deeply nested AutoValue row classes
When it happens
Trigger: Using AutoValueSchema for a type whose generated AutoValue_ class exposes neither a builder nor a constructor the creator-factory lookup recognizes — e.g. the class isn't actually an @AutoValue class (descriptor points at the abstract class), code generation failed, or beam-schemas can't see the generated constructor via the AbstractGetterTypeSupplier.
Common situations: Forgetting the @AutoValue annotation so no AutoValue_Foo class was generated; annotation processing disabled in the build; nested/private AutoValue classes; shaded or relocated generated classes invisible at runtime; using interfaces annotated @AutoValue incorrectly.
Related errors
- Unable to generate a creator for class
- Unexpected null number for
- A schema is required to write non-schema'd data.
- All dicts in batch must have the same keys. extra keys
- An explicit schema is required to write non-schema'd…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/03ddf425f1ea0dfb.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/AutoValueSchema.java:135
new DefaultTypeConversionsFactory());
}
// Try to find a generated builder class. If one exists, use that to generate a
// SchemaTypeCreator for creating AutoValue objects.
SchemaUserTypeCreator creatorFactory =
AutoValueUtils.getBuilderCreator(
targetTypeDescriptor, schema, AbstractGetterTypeSupplier.INSTANCE);
if (creatorFactory != null) {
return creatorFactory;
}
// If there is no builder, there should be a package-private constructor in the generated
// class. Use that for creating AutoValue objects.
creatorFactory =
AutoValueUtils.getConstructorCreator(
targetTypeDescriptor, schema, AbstractGetterTypeSupplier.INSTANCE);
if (creatorFactory == null) {
throw new RuntimeException(
"Could not find a way to create AutoValue class " + targetTypeDescriptor);
}
return creatorFactory;
}
@Override
public <T> @Nullable Schema schemaFor(TypeDescriptor<T> typeDescriptor) {
return JavaBeanUtils.schemaFromJavaBeanClass(
typeDescriptor, AbstractGetterTypeSupplier.INSTANCE);
}
}
View on GitHub (pinned to 12126d8942)