flowable/flowable-engine · error · FlowableIllegalArgumentException
Converter can only convert integers
Error message
Converter can only convert integers
What it means
LongRestVariableConverter.convertVariableValue serializes an engine variable to a REST variable and requires the value to be exactly java.lang.Long. Note the message says "integers" but the guard is instanceof Long: Integer, int, BigInteger, or other numeric types fail and throw FlowableIllegalArgumentException.
Solutions
- Convert the value to Long first: Long.valueOf(((Number) v).longValue()).
- Declare process variables as long/Long end-to-end so the engine stores java.lang.Long.
- If you genuinely need Integer variables, use the IntegerRestVariableConverter instead.
- Update the misleading message text in a patch if you maintain a fork, to say "Converter can only convert Long".
Example fix
// before int count = 42; converter.convertVariableValue(count, restVar); // throws (autoboxed to Integer) // after converter.convertVariableValue(Long.valueOf(count), restVar);
Defensive patterns
Strategy: type-guard
Validate before calling
if (value instanceof Long) {
converter.convertVariableValue(value, restVar);
} else if (value instanceof Number n) {
converter.convertVariableValue(n.longValue(), restVar);
} else {
throw new IllegalArgumentException("Cannot serialize as long: " + value.getClass());
} Type guard
static boolean isJavaLangLong(Object v) {
return v instanceof Long;
} Try / catch
try {
converter.convertVariableValue(value, restVar);
} catch (FlowableIllegalArgumentException e) {
throw new IllegalStateException("long REST variable requires java.lang.Long, got: "
+ value.getClass().getName(), e);
} Prevention
- Declare variables as long/Long end-to-end; avoid int/Integer for long-typed variables.
- Wrap numeric literals explicitly with Long.valueOf before adding to variable maps.
- Note the converter's message says 'integers' but the required type is Long — trust the instanceof, not the text.
When it happens
Trigger: Calling convertVariableValue with a non-null value that is not a Long — commonly an Integer, int (autoboxed), or BigInteger — when the variable is declared as a long REST type.
Common situations: Passing int/Integer literals into variable maps typed as long; ORM or JSON layers producing Integer/BigInteger; copy-paste from integer converters despite the misleading message text.
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
- Converter can only convert longs
- Converter can only convert…
- Converter can only convert localDate
- Converter can only convert localDateTime
- Converter can only convert shorts
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/3f8e861eb5a17d56.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-common-rest/src/main/java/org/flowable/common/rest/variable/LongRestVariableConverter.java:48
return Long.class;
}
@Override
public Object getVariableValue(EngineRestVariable result) {
if (result.getValue() != null) {
if (!(result.getValue() instanceof Number)) {
throw new FlowableIllegalArgumentException("Converter can only convert longs");
}
return ((Number) result.getValue()).longValue();
}
return null;
}
@Override
public void convertVariableValue(Object variableValue, EngineRestVariable result) {
if (variableValue != null) {
if (!(variableValue instanceof Long)) {
throw new FlowableIllegalArgumentException("Converter can only convert integers");
}
result.setValue(variableValue);
} else {
result.setValue(null);
}
}
}
View on GitHub (pinned to d6d39ce1c6)