pentaho/pentaho-kettle · error · KettleValueException

Script.Log.CouldNotAttachAdditionalScripts

Script.Log.CouldNotAttachAdditionalScripts

Error message

Script.Log.CouldNotAttachAdditionalScripts

What it means

Thrown in Script.addValues when the step fails while attaching additional script classes/objects (the AddClasses / additional scripts, e.g. Java classes exposed to the JavaScript scope) — any Exception during that setup is wrapped in a KettleValueException with this message. It occurs during per-row initialization of the JS scope, so it aborts the transformation run.

Solutions

  1. Remove any 'Java classes' / additional script entries from the step's config — this modified step does not support attaching them.
  2. Recreate the step metadata fresh rather than importing old ScriptValuesMod transformation XML.
  3. If classes are referenced, verify they exist on the classpath (libext/plugins) or drop the dependency.
  4. Move needed logic into the main transform script instead of additional classes.

Example fix

// before: step configured with a Java class entry in 'Add classes'
// after: delete the class entry and inline the logic in the main script
//   (the attach path is effectively unimplemented in this step)
Defensive patterns

Strategy: validation

Validate before calling

// before running: reject metadata carrying unsupported additional classes
if (meta.getAddClasses() != null && meta.getAddClasses().length > 0) {
  throw new IllegalStateException(
    "Additional Java classes are not supported by this Script step; remove them.");
}

Try / catch

try {
  step.processRow();
} catch (KettleValueException e) {
  if (e.getMessage().contains("CouldNotAttachAdditionalScripts")) {
    logError("Unsupported additional scripts/classes in step config", e);
  } else { throw e; }
}

Prevention

When it happens

Trigger: addValues (called from processRow) reaching the additional-scripts attach block and encountering any Exception while binding the configured additional script/class objects to the JavaScript scope (the property-binding code shown commented in the source).

Common situations: Transformations using legacy 'Java classes'/additional script features not implemented in this modified Script step (the code around it is commented out with TODO AKRETION); corrupt or unsupported step metadata carried over from ScriptValuesMod; classpath issues loading the referenced classes.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/script/Script.java:218

        //
        data.scope.put( "rowMeta", rowMeta );

        // Modification for Additional Script parsing
        //
        try {
          if ( meta.getAddClasses() != null ) {
            for ( int i = 0; i < meta.getAddClasses().length; i++ ) {
              // TODO AKRETION ensure it works
              data.scope.put( meta.getAddClasses()[ i ].getJSName(), meta.getAddClasses()[ i ].getAddObject() );
              // 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, "Script.Log.CouldNotAttachAdditionalScripts" ), e );
        }

        // Adding some default JavaScriptFunctions to the System
        // TODO AKRETION not implemented yet
        // 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, "Script.Log.CouldNotAddDefaultFunctions"), ex);
        // }
        // ;

        // Adding some Constants to the JavaScript

View on GitHub (pinned to f3058517a1)