apache/beam · error · RuntimeException
Unable to generate a creator for class {} with schema {}
Error message
Unable to generate a creator for class {} with schema {} What it means
JavaBeanUtils.createConstructorCreator generates a SchemaUserTypeCreator that invokes a Java bean's constructor to build rows from a Beam Schema. If instantiating the generated creator class fails via reflection (InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException), this RuntimeException naming the class and schema is thrown.
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/utils/JavaBeanUtils.java:366
.subclass(SchemaUserTypeCreator.class)
.method(ElementMatchers.named("create"))
.intercept(
new ConstructorCreateInstruction(
types, clazz, constructor, 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
| NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException(
"Unable to generate a creator for class " + clazz + " with schema " + schema);
}
}
public static SchemaUserTypeCreator getStaticCreator(
TypeDescriptor<?> typeDescriptor,
Method creator,
Schema schema,
FieldValueTypeSupplier fieldValueTypeSupplier,
TypeConversionsFactory typeConversionsFactory) {
return CACHED_CREATORS.computeIfAbsent(
TypeDescriptorWithSchema.create(typeDescriptor, schema),
c -> {
List<FieldValueTypeInformation> types =
fieldValueTypeSupplier.get(typeDescriptor, schema);
return createStaticCreator(
typeDescriptor.getRawType(), creator, schema, types, typeConversionsFactory);
});View on GitHub (pinned to 12126d8942)
Solutions
- Add a public no-arg constructor to the target class and make it concrete/public
- Verify the constructor parameters match the schema fields (types and order)
- Catch and inspect the cause exception to see which reflective step failed
- If the class cannot have a no-arg constructor, provide a static creator method instead (getStaticCreator path)
Example fix
// before
public class Row { public Row(String name) { ... } }
// after
public class Row { public Row() {} public Row(String name) { ... } } Defensive patterns
Strategy: validation
Validate before calling
static void checkCreatorTarget(Class<?> c) {
if (java.lang.reflect.Modifier.isAbstract(c.getModifiers()))
throw new IllegalArgumentException(c + " is abstract");
try { c.getDeclaredConstructor(); }
catch (NoSuchMethodException e) { throw new IllegalArgumentException("No no-arg constructor on " + c, e); }
} Type guard
static boolean canBeSchemaRow(Class<?> c) {
return java.lang.reflect.Modifier.isPublic(c.getModifiers())
&& !c.isInterface()
&& !java.lang.reflect.Modifier.isAbstract(c.getModifiers());
} Try / catch
try {
creator = JavaBeanUtils.getConstructorCreator(MyBean.class, schema, options);
} catch (RuntimeException e) {
throw new IllegalStateException("Creator generation failed for " + MyBean.class + " with schema " + schema, e);
} Prevention
- Provide a public no-arg constructor on all schema row classes
- Keep constructor parameter types aligned with schema field types
- Prefer simple POJOs; avoid constructors with side effects that can throw
- If no-arg ctor is impossible, expose a static factory creator instead
When it happens
Trigger: Calling JavaBeanUtils.getConstructorCreator/createConstructorCreator for a class whose constructor-based creator cannot be instantiated: the target class lacks an accessible no-arg constructor, is abstract, or constructor invocation throws at runtime.
Common situations: Using a bean without a public no-arg constructor as a schema type (e.g. with Schema.create/avro-like row encoding); constructor performing validation that throws on first invocation; class visibility mismatch across packages.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Unable to generate a setter for setter '%s'
- Unable to generate a have for hasMethod '%s'
- Unable to generate a creator for {} with schema {}
- Unable to generate a getter for getter '%s'
- Unable to generate builder factory for clazz
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/dde601e68a7ba268.
Report an issue: GitHub.