pentaho/pentaho-kettle · error · KettleValueException
ScriptValuesMod.Log.CouldNotAddDefaultFunctions
Error message
ScriptValuesMod.Log.CouldNotAddDefaultFunctions
What it means
After attaching user scripts, addValues() exposes Pentaho's built-in helper functions by calling Context.javaToJS(ScriptValuesAddedFunctions.class, ...) and defineFunctionProperties(jsFunctionList, ...) on the scope; any Exception is rethrown as KettleValueException with message ScriptValuesMod.Log.CouldNotAddDefaultFunctions. This indicates the standard script function library could not be registered, so built-in functions would be unavailable.
Solutions
- Check the cause stack trace ('ex') in the log to see whether the failure is in javaToJS or defineFunctionProperties.
- Verify the rhino jar on the classpath matches the one shipped with your Pentaho version; remove any manually upgraded rhino jar.
- Reinstall/refresh the scriptvalues_mod plugin so ScriptValuesAddedFunctions matches the step's expected version.
- Confirm data.scope comes from cx.initStandardObjects (a ScriptableObject) and was not replaced by custom scope code.
- If you patched ScriptValuesAddedFunctions, ensure every method listed in jsFunctionList keeps the exact static signature Rhino requires (public static, Context/Scriptable args).
Example fix
// before: custom newer rhino.jar placed in lib/ overriding Pentaho's bundled version lib/rhino-1.7.15-custom.jar // after: restore the bundled version lib/rhino-<pentaho-bundled-version>.jar
Defensive patterns
Strategy: try-catch
Validate before calling
// Java, sanity-check the script environment before executing the transformation
if (!(data.scope instanceof ScriptableObject))
throw new IllegalStateException("JS scope is not a ScriptableObject; initStandardObjects failed");
Class.forName("org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions");
// also verify no conflicting rhino jar: check ProtectionDomain of Context class Try / catch
try {
transformation.execute(params);
} catch (KettleValueException e) {
if (e.getMessage().contains("CouldNotAddDefaultFunctions")) {
log.error("Default function registration failed: " + e.getCause(), e.getCause());
// check rhino jar version / plugin install, then retry
} else { throw e; }
} Prevention
- Do not replace Pentaho's bundled rhino jar with a different version on the classpath.
- Reinstall the script step plugin if Pentaho was partially upgraded.
- If extending ScriptValuesAddedFunctions, keep every jsFunctionList entry's static signature exactly as Rhino's defineFunctionProperties expects.
- Confirm scope creation via cx.initStandardObjects so it is a ScriptableObject.
When it happens
Trigger: Context.javaToJS on ScriptValuesAddedFunctions.class or ((ScriptableObject) data.scope).defineFunctionProperties(ScriptValuesAddedFunctions.jsFunctionList, ScriptValuesAddedFunctions.class, DONTENUM) throws — typically because data.scope is not a ScriptableObject, the Rhino version's reflection of jsFunctionList fails, or method signature checks in defineFunctionProperties reject entries.
Common situations: Rhino version mismatch (custom/updated rhino jar on the classpath replacing the one Pentaho expects, so function-list reflection or method signatures differ); scope initialized in a way that yields a plain (non-ScriptableObject) object; corrupted/partial plugin install where ScriptValuesAddedFunctions class is from an incompatible plugin version.
Related errors
- ScriptValuesMod.Log.CouldNotAttachAdditionalScripts
- iae.getMessage()
- A deadlock was detected between steps
- AbsSecurityManager.ERROR_0003_UNABLE_TO_ACCESS_ROLE_BINDING_WEBSVC
- AbsSecurityManager.ERROR_0004_UNABLE_TO_APPLY_LOGICAL_ROLES_TO_RUNTIME_ROLE
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/5cb832f126587bac.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java:274
for ( int i = 0; i < meta.getAddClasses().length; i++ ) {
Object jsOut = Context.javaToJS( meta.getAddClasses()[ i ].getAddObject(), data.scope );
ScriptableObject.putProperty( data.scope, meta.getAddClasses()[ i ].getJSName(), jsOut );
}
}
} catch ( Exception e ) {
throw new KettleValueException( BaseMessages.getString(
PKG, "ScriptValuesMod.Log.CouldNotAttachAdditionalScripts" ), e );
}
// Adding some default JavaScriptFunctions to the System
try {
Context.javaToJS( ScriptValuesAddedFunctions.class, data.scope );
( (ScriptableObject) data.scope ).defineFunctionProperties(
ScriptValuesAddedFunctions.jsFunctionList, ScriptValuesAddedFunctions.class,
ScriptableObject.DONTENUM );
} catch ( Exception ex ) {
// System.out.println(ex.toString());
throw new KettleValueException( BaseMessages.getString(
PKG, "ScriptValuesMod.Log.CouldNotAddDefaultFunctions" ), ex );
}
// Adding some Constants to the JavaScript
try {
data.scope.put( "SKIP_TRANSFORMATION", data.scope, Integer.valueOf( SKIP_TRANSFORMATION ) );
data.scope.put( "ABORT_TRANSFORMATION", data.scope, Integer.valueOf( ABORT_TRANSFORMATION ) );
data.scope.put( "ERROR_TRANSFORMATION", data.scope, Integer.valueOf( ERROR_TRANSFORMATION ) );
data.scope.put( "CONTINUE_TRANSFORMATION", data.scope, Integer.valueOf( CONTINUE_TRANSFORMATION ) );
} catch ( Exception ex ) {
// System.out.println("Exception Adding the Constants " + ex.toString());
throw new KettleValueException( BaseMessages.getString(
PKG, "ScriptValuesMod.Log.CouldNotAddDefaultConstants" ), ex );
}
try {View on GitHub (pinned to f3058517a1)