pentaho/pentaho-kettle · error · KettleValueException

: I don't know how to convert a serializable to binary.

Error message

 : I don't know how to convert a serializable to binary.

What it means

ValueMetaBase.getBinary() cannot convert TYPE_SERIALIZABLE values (arbitrary Java objects) into binary bytes; KettleValueException is thrown. There is no defined serialization step inside the value meta layer, so serializable fields must be handled with explicit code (e.g. Java serialization or toString).

Solutions

  1. Explicitly serialize the object with ObjectOutputStream in the producing step and store the byte[] in a TYPE_BINARY field.
  2. Convert the object to a string (toString()/custom formatter) and call getBinary on a TYPE_STRING meta.
  3. Change the field metadata to a concrete supported type at the point where it is created.
  4. Catch KettleValueException and skip/handle serializable fields explicitly in generic serialization loops.

Example fix

// before
ValueMetaInterface vm = new ValueMeta("obj", ValueMetaInterface.TYPE_SERIALIZABLE);
byte[] b = vm.getBinary(myObject); // throws
// after
ByteArrayOutputStream bos = new ByteArrayOutputStream();
new ObjectOutputStream(bos).writeObject(myObject);
ValueMetaInterface vmBin = new ValueMeta("obj", ValueMetaInterface.TYPE_BINARY);
byte[] b = vmBin.getBinary(bos.toByteArray());
Defensive patterns

Strategy: type-guard

Validate before calling

if (meta.getType() == ValueMetaInterface.TYPE_SERIALIZABLE) { throw new IllegalArgumentException("Field " + meta.getName() + " is serializable; serialize explicitly before getBinary()"); }

Type guard

boolean isBinaryReadable(ValueMetaInterface vm) { return vm.getType() == ValueMetaInterface.TYPE_STRING || vm.getType() == ValueMetaInterface.TYPE_BINARY; }

Try / catch

try { byte[] b = vm.getBinary(value); } catch (KettleValueException e) { byte[] b = value instanceof java.io.Serializable ? serialize(value) : vm.getString(value).getBytes(); }

Prevention

When it happens

Trigger: Calling getBinary(object) on a value meta whose type is ValueMetaInterface.TYPE_SERIALIZABLE, e.g. fields emitted by User Defined Java Class or plugin steps holding raw objects.

Common situations: UDJC/script steps pushing Java objects into the stream that a downstream binary/text output tries to read as bytes; generic field serialization utilities; binary file outputs receiving object fields.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:2411

          case STORAGE_TYPE_NORMAL:
            return convertStringToBinaryString( (String) object );
          case STORAGE_TYPE_BINARY_STRING:
            return (byte[]) object;
          case STORAGE_TYPE_INDEXED:
            return convertStringToBinaryString( (String) index[( (Integer) object ).intValue()] );
          default:
            throw new KettleValueException( toString() + " : Unknown storage type " + storageType + " specified." );
        }
      case TYPE_NUMBER:
        throw new KettleValueException( toString() + " : I don't know how to convert a number to binary." );
      case TYPE_INTEGER:
        throw new KettleValueException( toString() + " : I don't know how to convert an integer to binary." );
      case TYPE_BIGNUMBER:
        throw new KettleValueException( toString() + " : I don't know how to convert a bignumber to binary." );
      case TYPE_BOOLEAN:
        throw new KettleValueException( toString() + " : I don't know how to convert a boolean to binary." );
      case TYPE_SERIALIZABLE:
        throw new KettleValueException( toString() + " : I don't know how to convert a serializable to binary." );

      default:
        throw new KettleValueException( toString() + " : Unknown type " + type + " specified." );
    }
  }

  @Override
  public byte[] getBinaryString( Object object ) throws KettleValueException {
    // If the input is a binary string, we should return the exact same binary
    // object IF
    // and only IF the formatting options for the storage metadata and this
    // object are the same.
    //
    if ( isStorageBinaryString() && identicalFormat ) {
      return (byte[]) object; // shortcut it directly for better performance.
    }

    try {

View on GitHub (pinned to f3058517a1)