apache/beam · error · RuntimeException
Unable to generate a creator for POJO '%s' with inferred sch
Error message
Unable to generate a creator for POJO '%s' with inferred schema: %s%nNote POJOs must have a zero-argument constructor, or a constructor annotated with @SchemaCreate.
What it means
createSetFieldCreator instantiates a POJO for schema-based row conversion by invoking a zero-argument constructor (or an @SchemaCreate-annotated constructor/method). If instantiation fails — the class is abstract, has no accessible no-arg constructor, the constructor throws, or a method is missing — it throws this RuntimeException with a hint about the @SchemaCreate annotation. The original reflective exception is swallowed, so only the formatted message is visible.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/POJOUtils.java:177
.subclass(SchemaUserTypeCreator.class)
.method(ElementMatchers.named("create"))
.intercept(new SetFieldCreateInstruction(types, clazz, typeConversionsFactory));
return builder
.visit(new AsmVisitorWrapper.ForDeclaredMethods().writerFlags(ClassWriter.COMPUTE_FRAMES))
.make()
.load(
ReflectHelpers.findClassLoader(clazz.getClassLoader()),
getClassLoadingStrategy(clazz))
.getLoaded()
.getDeclaredConstructor()
.newInstance();
} catch (InstantiationException
| IllegalAccessException
| IllegalStateException
| NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException(
String.format(
"Unable to generate a creator for POJO '%s' with inferred schema: %s%nNote POJOs must"
+ " have a zero-argument constructor, or a constructor annotated with"
+ " @SchemaCreate.",
clazz, schema));
}
}
public static <T> SchemaUserTypeCreator getConstructorCreator(
TypeDescriptor<T> typeDescriptor,
Constructor<T> constructor,
Schema schema,
FieldValueTypeSupplier fieldValueTypeSupplier,
TypeConversionsFactory typeConversionsFactory) {
return CACHED_CREATORS.computeIfAbsent(
TypeDescriptorWithSchema.create(typeDescriptor, schema),
c -> {
List<FieldValueTypeInformation> types =View on GitHub (pinned to 12126d8942)
Solutions
- Add a public zero-argument constructor to the POJO (e.g. Lombok @NoArgsConstructor).
- If zero-arg construction is impossible, annotate a static factory method or suitable constructor with @org.apache.beam.sdk.schemas.SchemaCreate so Beam uses it to build instances.
- Make sure the class is public, static (if nested), and concrete (not abstract/interface).
- Check whether the no-arg constructor throws on default field values (e.g. Objects.requireNonNull) and relax that validation for schema-created instances.
Example fix
// before
public class User {
private final String name;
public User(String name) { this.name = name; }
}
// after
public class User {
private String name;
public User() {} // zero-arg constructor for Beam
public User(String name) { this.name = name; }
}
// or: @SchemaCreate public static User create(String name) { ... } Defensive patterns
Strategy: validation
Validate before calling
Class<?> clazz = MyPojo.class;
boolean ok = Modifier.isPublic(clazz.getModifiers()) && !Modifier.isAbstract(clazz.getModifiers())
&& java.util.Arrays.stream(clazz.getConstructors()).anyMatch(c -> c.getParameterCount() == 0)
|| java.util.Arrays.stream(clazz.getDeclaredMethods())
.anyMatch(m -> m.isAnnotationPresent(org.apache.beam.sdk.schemas.SchemaCreate.class));
if (!ok) throw new IllegalStateException(clazz + " needs a public no-arg ctor or @SchemaCreate"); Try / catch
try {
SchemaUserTypeCreator creator = POJOUtils.getSetFieldCreator(clazz, schema);
} catch (RuntimeException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Unable to generate a creator for POJO")) {
throw new IllegalStateException("Fix POJO: add no-arg constructor or @SchemaCreate", e);
} else throw e;
} Prevention
- Give every schema POJO a public zero-argument constructor by convention.
- Use Lombok @NoArgsConstructor @AllArgsConstructor together for immutable-style POJOs.
- Never let the no-arg constructor throw validation errors; validate in setters or a factory instead.
When it happens
Trigger: Calling getSetFieldCreator on a POJO class that lacks a public zero-argument constructor and lacks a constructor/method annotated with @SchemaCreate; or whose no-arg constructor itself throws; or an abstract/interface class.
Common situations: POJOs defined with only all-args constructors (Lombok @AllArgsConstructor without @NoArgsConstructor), immutable value classes, inner non-static classes whose constructor requires an enclosing instance, or classes whose constructor validates and throws on default values.
Related errors
- Was not able to generate getters for schema: {} class: {}
- Unable to generate a creator for {} with schema {}
- Unable to generate a creator for class {} with schema {}
- Could not determine array parameter type for field.
- Cound not determine array parameter type for field.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5a215a29adf1c78b.
Report an issue: GitHub.