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
- Make the setter method public
- Make the delegate class public (nested classes too)
- If modules are used, export/open the package to activiti-engine
- 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
- Make all injected setters and delegate classes public
- Avoid nested/inner delegate classes or make them public static
- Re-check accessibility after introducing Java modules
- Include field-injection tests in CI
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
- Error while invoking
- Exception while invoking
- Field definition uses unexisting field
- Illegal access when calling
- businessCalendars can not be null
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)