pentaho/pentaho-kettle · error · UnsupportedOperationException

JavaScript conversion to BigNumber not implemented for

Error message

JavaScript conversion to BigNumber not implemented for ${classType}

What it means

jsToBigNumber() converts a JS value to a BigDecimal only when the classType is java.lang.Long, java.lang.Double, or java.lang.String. Any other declared classType falls through to UnsupportedOperationException with this message. It is an unimplemented conversion path in JavaScriptUtils.

Solutions

  1. Cast or coerce the script result to a Number or String before output (e.g. use Number(value) or value.toString()).
  2. Change the output field type to Number/String to match the actual value class, then convert downstream.
  3. Normalize the value in JavaScript so its Java class is java.lang.Long, java.lang.Double, or java.lang.String.

Example fix

// before
var result = new java.lang.Integer(42); // Integer unsupported for BigNumber
// after
var result = new java.lang.Long(42); // or Number(42) / "42"
Defensive patterns

Strategy: type-guard

Type guard

function isBigNumberCompatible(v) {
  var c = v != null ? v.getClass().getName() : null;
  return c === "java.lang.Long" || c === "java.lang.Double" || c === "java.lang.String";
}

Try / catch

try {
  Object result = JavaScriptUtils.convertFromJs(context, value, fieldName, classType);
} catch (UnsupportedOperationException e) {
  // coerce to String and retry, or change field type to Number
}

Prevention

When it happens

Trigger: convertFromJs routes a value to jsToBigNumber for a BigNumber output field whose value's runtime classType string is none of the handled types (e.g. java.lang.Integer, java.lang.BigDecimal, java.lang.Boolean, or a JS-native wrapper reported differently).

Common situations: Script returns an Integer/Boolean/Date while the output field is BigNumber; value passed through JS code changes its native Java class from what the metadata expects; newer Pentaho/JS engine reports wrapper types not covered by the if-chain.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/core/util/JavaScriptUtils.java:191

      Number nb = Context.toNumber( value );
      return BigDecimal.valueOf( nb.doubleValue() );
    } else if ( classType.equalsIgnoreCase( JS_NATIVE_JAVA_OBJ ) ) {
      // Is it a BigDecimal class ?
      return convertNativeJavaToBigDecimal( value );
    } else if ( classType.equalsIgnoreCase( "java.lang.Byte" ) ) {
      return BigDecimal.valueOf( ( (Byte) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Short" ) ) {
      return BigDecimal.valueOf( ( (Short) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Integer" ) ) {
      return BigDecimal.valueOf( ( (Integer) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Long" ) ) {
      return BigDecimal.valueOf( ( (Long) value ).longValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.Double" ) ) {
      return BigDecimal.valueOf( ( (Double) value ).doubleValue() );
    } else if ( classType.equalsIgnoreCase( "java.lang.String" ) ) {
      return BigDecimal.valueOf( ( new Long( (String) value ) ).longValue() );
    } else {
      throw new UnsupportedOperationException( "JavaScript conversion to BigNumber not implemented for " + classType );
    }
  }

  private static BigDecimal convertNativeJavaToBigDecimal( Object value ) {
    try {
      return (BigDecimal) Context.jsToJava( value, BigDecimal.class );
    } catch ( Exception e ) {
      try {
        Value v = (Value) Context.jsToJava( value, Value.class );
        if ( !v.isNull() ) {
          return v.getBigNumber();
        } else {
          return null;
        }
      } catch ( Exception e2 ) {
        String string = (String) Context.jsToJava( value, String.class );
        return new BigDecimal( string );
      }

View on GitHub (pinned to f3058517a1)