{"record":{"id":"1bb8d7de0f12ef59","repo":"Activiti/Activiti","slug":"illegal-acces-when-calling-declaration-getname","errorCode":null,"errorMessage":"Illegal acces when calling '${declaration.getName()}' on class ${target.getClass().getName()}","messagePattern":"Illegal acces when calling '(.+?)' on class (.+?)","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/helper/ClassDelegate.java","lineNumber":429,"sourceCode":"        Object target,\n        boolean throwExceptionOnMissingField\n    ) {\n        Method setterMethod = ReflectUtil.getSetter(\n            declaration.getName(),\n            target.getClass(),\n            declaration.getValue().getClass()\n        );\n\n        if (setterMethod != null) {\n            try {\n                setterMethod.invoke(target, declaration.getValue());\n            } catch (IllegalArgumentException e) {\n                throw new ActivitiException(\n                    \"Error while invoking '\" + declaration.getName() + \"' on class \" + target.getClass().getName(),\n                    e\n                );\n            } catch (IllegalAccessException e) {\n                throw new ActivitiException(\n                    \"Illegal acces when calling '\" +\n                    declaration.getName() +\n                    \"' on class \" +\n                    target.getClass().getName(),\n                    e\n                );\n            } catch (InvocationTargetException e) {\n                throw new ActivitiException(\n                    \"Exception while invoking '\" + declaration.getName() + \"' on class \" + target.getClass().getName(),\n                    e\n                );\n            }\n        } else {\n            Field field = ReflectUtil.getField(declaration.getName(), target);\n            if (field == null) {\n                if (throwExceptionOnMissingField) {\n                    throw new ActivitiIllegalArgumentException(\n                        \"Field definition uses unexisting field '\" +","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/helper/ClassDelegate.java#L411-L447","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvoid setFoo(String foo) { this.foo = foo; }\n// after\npublic void setFoo(String foo) { this.foo = foo; }","handlingStrategy":"validation","validationCode":"for (Method m : delegateClass.getDeclaredMethods()) {\n  if (m.getName().startsWith(\"set\") && !Modifier.isPublic(m.getModifiers())) {\n    throw new IllegalStateException(\"Setter \" + m.getName() + \" must be public for field injection\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  runtimeService.startProcessInstanceByKey(\"myProcess\", vars);\n} catch (ActivitiException e) {\n  if (e.getMessage().startsWith(\"Illegal acces\")) { log.error(\"Non-public setter in delegate: \" + e.getMessage()); }\n  else throw e;\n}","preventionTips":["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"],"tags":["java","reflection","field-injection","access-modifier","activiti"],"backgroundTag":"permission-denied","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}