pentaho/pentaho-kettle · error · KettleException
Constructor not found for
Error message
Constructor not found for
What it means
Companion to 'Can't create object': after scanning the constructors of the target class, createObject() found no no-arg constructor and no single-arg constructor accepting the root, and throws this KettleException.
Solutions
- Add a public no-arg constructor
- Add a public constructor whose single parameter type is assignable from the root class
- Change the injection property type to a class with a supported constructor
Example fix
// before
class Child { public Child(String mandatory){...} }
// after
class Child { public Child(){...} public Child(String mandatory){...} } Defensive patterns
Strategy: validation
Validate before calling
// Same constructor-shape check as the create-failure variant
boolean hasCtor = Arrays.stream(targetClass.getConstructors()).anyMatch(k ->
k.getParameterCount() == 0
|| (k.getParameterCount() == 1 && k.getParameterTypes()[0].isAssignableFrom(rootClass)));
if (!hasCtor) throw new IllegalStateException("Constructor not found for " + targetClass); Type guard
static boolean hasSupportedConstructor(Class<?> c, Class<?> root) {
try { c.getDeclaredConstructor(); return true; }
catch (NoSuchMethodException e) {
return Arrays.stream(c.getConstructors()).anyMatch(k ->
k.getParameterCount() == 1 && k.getParameterTypes()[0].isAssignableFrom(root));
}
} Try / catch
try {
injector.injectValue(bean, path, value);
} catch (KettleException e) {
if (e.getMessage().startsWith("Constructor not found")) {
log.error("Add a no-arg or root-arg constructor for: " + e.getMessage(), e);
} else throw e;
} Prevention
- Mandatory-arg classes need an extra no-arg or root-arg constructor to participate in injection
- Cover nested bean instantiation in injection tests
When it happens
Trigger: Reflection-based instantiation of a nested injection-path class where only constructors with incompatible signatures exist (e.g. required extra parameters).
Common situations: Value objects with builder-only construction; classes requiring DI-injected dependencies; Kotlin/Java classes with mandatory constructor args.
Related errors
- Can't create object
- DefaultAuthenticationConsumerFactory.Constructor
- DefaultAuthenticationConsumerFactory.Constructor.Arg
- No field or getter defined for
- No field or setter defined for
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/4e58c3b750f8b044.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/core/injection/bean/BeanInjector.java:342
}
}
return true;
}
private Object createObject( Class<?> clazz, Object root ) throws KettleException {
try {
// Object can be inner of metadata class. In this case constructor will require parameter
for ( Constructor<?> c : clazz.getConstructors() ) {
if ( c.getParameterTypes().length == 0 ) {
return clazz.newInstance();
} else if ( c.getParameterTypes().length == 1 && c.getParameterTypes()[0].isAssignableFrom( info.clazz ) ) {
return c.newInstance( root );
}
}
} catch ( Throwable ex ) {
throw new KettleException( "Can't create object " + clazz, ex );
}
throw new KettleException( "Constructor not found for " + clazz );
}
private Object extendArray( BeanLevelInfo s, Object obj, int newSize ) throws Exception {
Object existArray = s.field.get( obj );
if ( existArray == null ) {
existArray = Array.newInstance( s.leafClass, newSize );
s.field.set( obj, existArray );
}
int existSize = Array.getLength( existArray );
if ( existSize < newSize ) {
Object newSized = Array.newInstance( s.leafClass, newSize );
System.arraycopy( existArray, 0, newSized, 0, existSize );
existArray = newSized;
s.field.set( obj, existArray );
}
return existArray;
}View on GitHub (pinned to f3058517a1)