pentaho/pentaho-kettle · error · KettleValueException
ScriptValuesMod.Log.CouldNotAddDefaultConstants
Error message
ScriptValuesMod.Log.CouldNotAddDefaultConstants
What it means
Thrown by ScriptValuesMod.addValues() when registering the built-in transformation constants (ABORT_TRANSFORMATION, ERROR_TRANSFORMATION, CONTINUE_TRANSFORMATION) into the JavaScript scope fails. The step wraps Context/Scope initialization in a try-catch and rethrows any Exception as a KettleValueException with this localized message, chaining the original cause. It means the Rhino scripting environment could not be seeded with default constants before running the user script.
Solutions
- Read the chained cause ('Caused by') of the KettleValueException to identify the underlying Rhino error
- Restart the transformation/Kettle JVM to reset the scripting Context
- Check for mismatched Rhino/Mozilla JavaScript library versions on the classpath (duplicate js.jar)
- Verify the step is not being initialized concurrently/re-entrantly with a shared scope
- Upgrade to a Pentaho/Kettle version with fixed script values mod initialization
Example fix
// before: catching generic Exception hides the real cause
throw new KettleValueException( BaseMessages.getString( PKG, "ScriptValuesMod.Log.CouldNotAddDefaultConstants" ), ex );
// after (user side): inspect the full cause chain
try {
step.processRow( meta, data );
} catch ( KettleValueException e ) {
logError( "Script init failed", e ); // full stacktrace shows Rhino root cause
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before running, ensure no duplicate Rhino js jars and a fresh JVM // e.g. in a shell: find $KETTLE_CLASSPATH -name 'js*.jar' | sort # should list at most one
Try / catch
try {
step.processRow( meta, data );
} catch ( KettleValueException e ) {
Throwable root = e;
while ( root.getCause() != null ) { root = root.getCause(); }
logError( "Script constants init failed, root cause: " + root, e );
throw e;
} Prevention
- Keep exactly one Rhino/JavaScript library version on the classpath
- Restart the JVM after upgrading Kettle or scripting libraries
- Don't share or re-enter scripting scopes across transformations concurrently
When it happens
Trigger: An Exception (e.g. Rhino ContextException or illegal scope state) is raised while calling data.scope.put(...) for ABORT_TRANSFORMATION / ERROR_TRANSFORMATION / CONTINUE_TRANSFORMATION inside addValues(), invoked from processRow during step initialization of the Modified Java Script Value step.
Common situations: Corrupted or re-entered Rhino Context (Context.enter/exit imbalance), a non-scriptable or already-finalized scope object, or an unexpected internal Rhino exception during scope property definition; typically seen after JVM/Rhino version changes rather than by user misconfiguration.
Related errors
- Error in isEmpty function:
- The function call getLastModifiedTime is not valid.
- The function call isEmpty is not valid
- The function call trunc requires 1 argument, a number.
- Argument of TRUNC of date has to be between 0 and 5
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/9d7e77df092de506.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java:288
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 {
// Checking for StartScript
if ( strStartScript != null && strStartScript.length() > 0 ) {
Script startScript = data.cx.compileString( strStartScript, "trans_Start", 1, null );
startScript.exec( data.cx, data.scope );
if ( log.isDetailed() ) {
logDetailed( ( "Start Script found!" ) );
}
} else {
if ( log.isDetailed() ) {
logDetailed( ( "No starting Script found!" ) );
}
}
} catch ( Exception es ) {
// System.out.println("Exception processing StartScript " + es.toString());View on GitHub (pinned to f3058517a1)