Activiti/Activiti · error · ActivitiException

Illegal acces when calling

Error message

Illegal acces when calling '${declaration.getName()}' on class ${target.getClass().getName()}

What it means

Thrown by ClassDelegate.applyFieldDeclaration() when reflective setter invocation fails with IllegalAccessException — the setter method is not accessible from Activiti's reflection context (e.g. non-public setter, or public method in a package-private/class hidden class). Wrapped in ActivitiException; message contains a typo ('Illegal acces') from the library itself.

Solutions

  1. Make the setter method public
  2. Make the delegate class public (nested classes too)
  3. If modules are used, export/open the package to activiti-engine
  4. Alternatively define a public field and rely on field injection instead of setter injection

Example fix

// before
void setFoo(String foo) { this.foo = foo; }
// after
public void setFoo(String foo) { this.foo = foo; }
Defensive patterns

Strategy: validation

Validate before calling

for (Method m : delegateClass.getDeclaredMethods()) {
  if (m.getName().startsWith("set") && !Modifier.isPublic(m.getModifiers())) {
    throw new IllegalStateException("Setter " + m.getName() + " must be public for field injection");
  }
}

Try / catch

try {
  runtimeService.startProcessInstanceByKey("myProcess", vars);
} catch (ActivitiException e) {
  if (e.getMessage().startsWith("Illegal acces")) { log.error("Non-public setter in delegate: " + e.getMessage()); }
  else throw e;
}

Prevention

When it happens

Trigger: BPMN <activiti:field> resolves a setter method that exists but is not public (or not accessible due to module/classloader restrictions); setterMethod.invoke(target, value) throws IllegalAccessException.

Common situations: Defining package-private or protected setters in delegate classes; delegate inner/nested classes without public visibility; Java module/Jigsaw accessibility restrictions; SecurityManager or classloader isolation blocking access.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of Activiti/Activiti@56435b1a97 (2026-09-09). Data as JSON: /api/errors/1bb8d7de0f12ef59. Report an issue: GitHub.

Appendix: source

Thrown at activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/helper/ClassDelegate.java:429

        Object target,
        boolean throwExceptionOnMissingField
    ) {
        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 acces 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) {
                if (throwExceptionOnMissingField) {
                    throw new ActivitiIllegalArgumentException(
                        "Field definition uses unexisting field '" +

View on GitHub (pinned to 56435b1a97)