pentaho/pentaho-kettle · error · KettleException

iae.getMessage()

Error message

iae.getMessage()

What it means

Immediately after the NumberFormatException handler, addValues() catches IllegalArgumentException from the Rhino Context initialization (setOptimizationLevel / factory setup) and rethrows a KettleException whose message is simply iae.getMessage(). This surfaces an underlying Rhino IllegalArgumentException directly to the step log, usually meaning the optimization level integer is outside Rhino's supported range or the context factory rejected the configuration.

Solutions

  1. Read the raw message in the log — it is the underlying Rhino IllegalArgumentException text — and correct the optimization level accordingly.
  2. Set the Optimization level to a safe value supported by the bundled Rhino (commonly -1 for interpreted mode).
  3. If this appeared after a Pentaho upgrade, check the Rhino version bundled with your Pentaho release for supported optimization levels and adjust the step config.
  4. Avoid exotic values; stick to documented levels (-1, 0, or the documented maximum).

Example fix

// before
<optimizationLevel>10</optimizationLevel>  <!-- outside supported Rhino range -->
// after
<optimizationLevel>-1</optimizationLevel>  <!-- interpreted mode, universally supported -->
Defensive patterns

Strategy: try-catch

Validate before calling

// Java, check the optimization level is within the supported Rhino range before running
int lvl = Integer.parseInt(environmentSubstitute(meta.getOptimizationLevel()).trim());
if (lvl != -1 && (lvl < 0 || lvl > 9))
  throw new IllegalArgumentException("Optimization level " + lvl + " not supported by bundled Rhino");

Try / catch

try {
  transformation.execute(params);
} catch (KettleException e) {
  // message is raw iae.getMessage() from Rhino — log it fully
  log.error("Rhino rejected script context config: " + e.getMessage(), e);
  // reset optimization level to -1 (interpreted) and retry once
}

Prevention

When it happens

Trigger: Context.enter()/setOptimizationLevel(Integer.parseInt(...)) receives a syntactically valid integer that is semantically invalid for Rhino (e.g. optimization level outside the allowed range for the bundled Rhino version), or Context factory rejects the requested setting inside addValues().

Common situations: User set optimization level 9 or higher while the embedded Rhino build only supports -1..0 (or vice versa after a Pentaho/Rhino upgrade changed supported levels); passing an extreme negative number other than -1; migrating a transformation between Pentaho versions where the default Rhino context limits differ.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/827d852218507432. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesMod.java:190

      data.cx = ContextFactory.getGlobal().enterContext();

      try {
        String optimizationLevelAsString = environmentSubstitute( meta.getOptimizationLevel() );
        if ( !Utils.isEmpty( Const.trim( optimizationLevelAsString ) ) ) {
          data.cx.setOptimizationLevel( Integer.parseInt( optimizationLevelAsString.trim() ) );
          logBasic( BaseMessages.getString( PKG, "ScriptValuesMod.Optimization.Level", environmentSubstitute( meta
            .getOptimizationLevel() ) ) );
        } else {
          data.cx.setOptimizationLevel( Integer.parseInt( ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );
          logBasic( BaseMessages.getString(
            PKG, "ScriptValuesMod.Optimization.UsingDefault", ScriptValuesMetaMod.OPTIMIZATION_LEVEL_DEFAULT ) );
        }
      } catch ( NumberFormatException nfe ) {
        throw new KettleStepException( BaseMessages.getString(
          PKG, "ScriptValuesMetaMod.Exception.NumberFormatException", environmentSubstitute( meta
            .getOptimizationLevel() ) ) );
      } catch ( IllegalArgumentException iae ) {
        throw new KettleException( iae.getMessage() );
      }

      data.scope = data.cx.initStandardObjects( null, false );

      bFirstRun = true;

      Scriptable jsvalue = Context.toObject( this, data.scope );
      data.scope.put( "_step_", data.scope, jsvalue );

      // Adding the existing Scripts to the Context
      for ( int i = 0; i < meta.getNumberOfJSScripts(); i++ ) {
        Scriptable jsR = Context.toObject( jsScripts[ i ].getScript(), data.scope );
        data.scope.put( jsScripts[ i ].getScriptName(), data.scope, jsR );
      }

      // Adding the Name of the Transformation to the Context
      data.scope.put( "_TransformationName_", data.scope, getTransMeta().getName() );

View on GitHub (pinned to f3058517a1)