flowable/flowable-engine · error · ActivitiException

Exception while invoking '%s' on class %s

Error message

Exception while invoking '%s' on class %s

What it means

Thrown when the setter invoked via reflection to apply a BPMN field injection raised an InvocationTargetException, i.e. the delegate's own setter method threw an exception internally. The engine rewraps it as an ActivitiException naming the field and target class.

Source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/helper/ClassDelegateUtil.java:60

            for (FieldDeclaration declaration : fieldDeclarations) {
                applyFieldDeclaration(declaration, target);
            }
        }
    }

    public static void applyFieldDeclaration(FieldDeclaration declaration, Object target) {
        Method setterMethod = ReflectUtil.getSetter(declaration.getName(),
                target.getClass(), declaration.getValue().getClass());

        if (setterMethod != null) {
            try {
                setterMethod.invoke(target, declaration.getValue());
            } catch (IllegalArgumentException e) {
                throw new ActivitiException("Error while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e);
            } catch (IllegalAccessException e) {
                throw new ActivitiException("Illegal access when calling '" + declaration.getName() + "' on class " + target.getClass().getName(), e);
            } catch (InvocationTargetException e) {
                throw new ActivitiException("Exception while invoking '" + declaration.getName() + "' on class " + target.getClass().getName(), e);
            }
        } else {
            Field field = ReflectUtil.getField(declaration.getName(), target);
            if (field == null) {
                throw new ActivitiIllegalArgumentException("Field definition uses unexisting field '" + declaration.getName() + "' on class " + target.getClass().getName());
            }
            // Check if the delegate field's type is correct
            if (!fieldTypeCompatible(declaration, field)) {
                throw new ActivitiIllegalArgumentException("Incompatible type set on field declaration '" + declaration.getName()
                        + "' for class " + target.getClass().getName()
                        + ". Declared value has type " + declaration.getValue().getClass().getName()
                        + ", while expecting " + field.getType().getName());
            }
            ReflectUtil.setField(field, target, declaration.getValue());
        }
    }

    public static boolean fieldTypeCompatible(FieldDeclaration declaration, Field field) {

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Inspect the cause stack trace: the real error is inside your delegate's setter
  2. Fix the exception thrown inside the setter (e.g. handle the injected value safely)
  3. Add null/format validation inside the setter before processing the value
  4. If the setter must not fail at injection time, defer the logic to the execute() method

Example fix

// before
public void setTimeout(String timeout) {
    this.timeout = Integer.parseInt(timeout); // throws on non-numeric
}
// after
public void setTimeout(String timeout) {
    this.timeout = timeout != null ? Integer.parseInt(timeout) : 0;
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
    applyFieldDeclaration(declaration, target);
} catch (org.activiti.engine.ActivitiException e) {
    logger.error("Field injection failed on {}", declaration.getName(), e.getCause());
    throw e;
}

Prevention

When it happens

Trigger: The setter method for an injected flowable:field executes and throws any runtime exception (e.g. parsing an invalid literal, NPE on an assumed dependency) during ClassDelegateUtil.applyFieldDeclaration.

Common situations: Setters that validate/transform the injected value and throw on bad input; setters that depend on state not yet initialized at delegate instantiation; type conversion mistakes inside the setter.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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