flowable/flowable-engine · error · FlowableException

Cannot convert value of type

Error message

Cannot convert value of type 

What it means

convertToInteger is invoked by convertValue when an IO parameter is declared as type 'integer'. It accepts Numbers (via intValue()) and Strings (via Integer.valueOf on the trimmed value). If the value is neither, Flowable throws this FlowableException naming the actual Java class of the offending value.

Source

Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/DefaultVariableValueConversionHandler.java:77

            if (jsonNode.isString()) {
                return jsonNode.asString();
            }
            return jsonNode.toString();
        }
        return value.toString();
    }

    protected Integer convertToInteger(Object value) {
        if (value instanceof Integer intValue) {
            return intValue;
        }
        if (value instanceof Number number) {
            return number.intValue();
        }
        if (value instanceof String stringValue) {
            return Integer.valueOf(stringValue.trim());
        }
        throw new FlowableException("Cannot convert value of type " + value.getClass().getName() + " to Integer");
    }

    protected Long convertToLong(Object value) {
        if (value instanceof Long longValue) {
            return longValue;
        }
        if (value instanceof Number number) {
            return number.longValue();
        }
        if (value instanceof String stringValue) {
            return Long.valueOf(stringValue.trim());
        }
        throw new FlowableException("Cannot convert value of type " + value.getClass().getName() + " to Long");
    }

    protected Double convertToDouble(Object value) {
        if (value instanceof Double doubleValue) {
            return doubleValue;

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Ensure the value bound to the 'integer' parameter is a Number or a numeric String before calling the engine.
  2. Pre-parse the string yourself: Integer.valueOf(value.trim()) inside try/catch to surface a clearer error.
  3. Change the declared parameter type to one matching the actual value (e.g. 'string' or 'json').
  4. Add a custom VariableValueConversionHandler overriding convertToInteger to widen accepted input (e.g. parse BigDecimal).

Example fix

// before
execution.setVariable("count", java.util.List.of(1,2));
// after
execution.setVariable("count", 2);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(v instanceof Number) && !(v instanceof String s && s.trim().matches("-?\\d+"))) {
    throw new IllegalArgumentException("value for 'integer' parameter must be Number or numeric String: " + v.getClass());
}

Type guard

static boolean isIntegerCompatible(Object v) {
    return v instanceof Number || (v instanceof String s && !s.isBlank() && s.trim().matches("-?\\d+"));
}

Try / catch

try {
    Integer i = (Integer) conversionHandler.convertValue(v, "integer", mapper);
} catch (FlowableException e) {
    if (e.getMessage().contains("to Integer")) { /* coerce/fallback: log class name, use default */ }
    else throw e;
}

Prevention

When it happens

Trigger: Passing a Boolean, Date, ObjectNode, List, Map, or byte[] value where an 'integer' IO parameter is declared, e.g. process variables bound from a JSON payload that did not coerce to int.

Common situations: JSON integration returns nested objects/arrays mapped to integer parameters; form data submits booleans for numeric fields; upstream code changed a variable from Integer to String-with-suffix or Long object of wrong generic type that is fine for long but here fine too — mostly non-numeric object types.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/23f4626d05c427df. Report an issue: GitHub.