apache/beam · error · RuntimeException
Unable to find constructor for + factoryClass.getName()
Error message
Unable to find constructor for + factoryClass.getName()
What it means
InstanceBuilder.buildFromConstructor() throws RuntimeException 'Unable to find constructor for ' + factoryClass.getName() when reflection cannot locate a constructor matching the assembled argument types (wrapping NoSuchMethodException).
Source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/util/InstanceBuilder.java:260
try {
Constructor<?> constructor = factoryClass.getDeclaredConstructor(types);
checkState(
type.isAssignableFrom(factoryClass),
"Instance type %s must be assignable to %s",
factoryClass.getName(),
type.getSimpleName());
if (!constructor.isAccessible()) {
constructor.setAccessible(true);
}
Object[] args = arguments.toArray(new Object[arguments.size()]);
return type.cast(constructor.newInstance(args));
} catch (NoSuchMethodException e) {
throw new RuntimeException("Unable to find constructor for " + factoryClass.getName());
} catch (InvocationTargetException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(
"Failed to construct instance from " + "constructor " + factoryClass.getName(), e);
}
}
}
View on GitHub (pinned to 12126d8942)
Solutions
- Verify the class exposes a public constructor matching the supplied argument types
- Align the argument list with the constructor signature (types and count)
- Check the library version for signature changes
- Add a convenience constructor if you own the class
Example fix
// before: class only has MyThing(String) but built with no args
new InstanceBuilder().fromClassName("MyThing").build();
// after
new InstanceBuilder().fromClassName("MyThing").withArg("name").build(); Defensive patterns
Strategy: validation
Validate before calling
boolean hasCtor = java.util.Arrays.stream(factoryClass.getConstructors())
.anyMatch(c -> c.getParameterCount() == args.size());
if (!hasCtor) { throw new IllegalStateException("no public ctor with " + args.size() + " args"); } Try / catch
try { instance = builder.build(); } catch (RuntimeException e) { if (e.getMessage().startsWith("Unable to find constructor")) { /* align ctor signature */ } throw e; } Prevention
- Verify a public constructor matches the supplied argument types
- Check for signature changes between library versions
- Keep classes to be reflectively constructed with explicit public constructors
When it happens
Trigger: build() is called in constructor mode but no constructor of the factory class accepts the collected argument types — wrong arity, wrong types, or a no-arg constructor expected but only parameterized ones exist.
Common situations: Configured class has no matching constructor for the given options; class was refactored/renamed constructor signature between versions; autoboxing/primitive mismatches in the argument list.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Standard logical type '%s' does not have a zero-argument con
- Unable to generate a creator for POJO '%s' with inferred sch
- Unable to generate a creator for {} with schema {}
- Unable to generate a creator for class {} with schema {}
- Subclass of InferableFunction must override 'apply' method o
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/21b3b123a38deaf1.
Report an issue: GitHub.