flowable/flowable-engine · error · IllegalArgumentException

Cannot coerce property to array index:

Error message

Cannot coerce property to array index: 

What it means

ArrayELResolver.coerce throws IllegalArgumentException when the EL property used as an array index is neither a Number, Boolean, nor parseable String — e.g. an arbitrary object — and cannot be coerced to an int index.

Source

Thrown at modules/flowable-engine-common/src/main/java/org/flowable/common/engine/impl/javax/el/ArrayELResolver.java:328

	private static int coerce(Object property) {
		if (property instanceof Number) {
			return ((Number) property).intValue();
		}
		if (property instanceof Character) {
			return (Character) property;
		}
		if (property instanceof Boolean) {
			return (Boolean) property ? 1 : 0;
		}
		if (property instanceof String) {
			try {
				return Integer.parseInt((String) property);
			} catch (NumberFormatException e) {
				throw new IllegalArgumentException("Cannot parse array index: " + property, e);
			}
		}

		throw new IllegalArgumentException("Cannot coerce property to array index: " + property);
	}
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Make the index expression evaluate to a Number or numeric String.
  2. Replace the array with a Map if you intend non-integer keyed access.
  3. Inspect the index sub-expression's return type and fix the type mismatch.

Example fix

// before
engine.eval("${rows[date]}" )
// after
engine.eval("${rows[rowIndex]}") // rowIndex is an Integer in the EL context
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(indexProp instanceof Number) && !(indexProp instanceof String) && !(indexProp instanceof Boolean)) throw new IllegalArgumentException("index not coercible: " + indexProp);

Type guard

boolean isCoercibleIndex(Object p) { return p instanceof Number || p instanceof Boolean || (p instanceof String s && s.matches("-?\\d+")); }

Try / catch

try { resolver.getValue(ctx, base, prop); } catch (IllegalArgumentException e) { /* fix index expression type */ }

Prevention

When it happens

Trigger: Evaluating ${myArray[someObject]} or ${myArray[true && x]} where the property resolves to a non-coercible type such as a POJO, List, or Date.

Common situations: Using map/object property syntax against arrays; an index expression accidentally returning a complex object instead of a number.

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/a2d3c4476353c385. Report an issue: GitHub.