flowable/flowable-engine · error · ActivitiIllegalArgumentException

Priority expression does not resolve to a number: %s

Error message

Priority expression does not resolve to a number: %s

What it means

Thrown when a user task's priority expression resolves to a value that is neither a String nor a Number (e.g. a Boolean, Date, or custom object). The behavior only supports String parseable as integer and Number types; anything else hits this branch. Note the sibling error 'Priority does not resolve to a number' covers unparseable Strings; this one covers wrong types.

Source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java:182

                    throw new ActivitiIllegalArgumentException("Due date expression does not resolve to a Date or Date string: " +
                            activeDueDateExpression.getExpressionText());
                }
            }
        }

        if (activePriorityExpression != null) {
            final Object priority = activePriorityExpression.getValue(execution);
            if (priority != null) {
                if (priority instanceof String) {
                    try {
                        task.setPriority(Integer.valueOf((String) priority));
                    } catch (NumberFormatException e) {
                        throw new ActivitiIllegalArgumentException("Priority does not resolve to a number: " + priority, e);
                    }
                } else if (priority instanceof Number) {
                    task.setPriority(((Number) priority).intValue());
                } else {
                    throw new ActivitiIllegalArgumentException("Priority expression does not resolve to a number: " +
                            activePriorityExpression.getExpressionText());
                }
            }
        }

        if (activeCategoryExpression != null) {
            final Object category = activeCategoryExpression.getValue(execution);
            if (category != null) {
                if (category instanceof String) {
                    task.setCategory((String) category);
                } else {
                    throw new ActivitiIllegalArgumentException("Category expression does not resolve to a string: " +
                            activeCategoryExpression.getExpressionText());
                }
            }
        }

        if (activeFormKeyExpression != null) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Point the priority expression at a variable that is an Integer/Number, e.g. activiti:priority="${taskPriority}" with taskPriority set to an int.
  2. Rename or re-type the colliding variable so 'priority' isn't reused for a Date/object; set a dedicated numeric variable before the user task.
  3. If priority comes from a form, configure the form field as an integer with a sensible default.
  4. Example fix

Example fix

// before
execution.setVariable("priority", new java.util.Date());
<userTask activiti:priority="${priority}"/>
// after
execution.setVariable("taskPriority", 50);
<userTask activiti:priority="${taskPriority}"/>
Defensive patterns

Strategy: type-guard

Validate before calling

Object p = execution.getVariable("priority");
if (p != null && !(p instanceof Number) && !(p instanceof String)) {
    throw new IllegalArgumentException("priority variable has unsupported type " + p.getClass() + "; use Number or numeric String");
}

Type guard

static boolean isNumericPriority(Object v) {
    return v == null || v instanceof Number
        || (v instanceof String && ((String) v).trim().matches("-?\\d+"));
}

Try / catch

try {
    taskService.complete(taskId);
} catch (ActivitiIllegalArgumentException e) {
    if (e.getMessage().startsWith("Priority expression does not resolve")) {
        Object p = runtimeService.getVariable(executionId, "priority");
        log.error("priority expression resolved to non-numeric type {}: check expression text in message",
            p == null ? null : p.getClass(), e);
    }
    throw e;
}

Prevention

When it happens

Trigger: activiti:priority expression like ${priorityVar} where the variable holds a Boolean, Date, Map, POJO, or null-adjacent non-numeric object; the expression text is reported in the message for debugging.

Common situations: Reusing a variable named 'priority' already holding an unrelated type (e.g. a Date or JSON object) in the process; script tasks setting priority to a non-numeric type; copy-pasted expressions pointing at the wrong variable.

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