{"record":{"id":"fc2c6a9ab0b97e01","repo":"flowable/flowable-engine","slug":"couldn-t-execute-listener","errorCode":null,"errorMessage":"Couldn't execute listener","messagePattern":"Couldn't execute listener","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java","lineNumber":373,"sourceCode":"     * @author Joram Barrez\n     */\n    private static final class CallActivityListenersOperation implements AtomicOperation {\n\n        private List<ExecutionListener> listeners;\n\n        private CallActivityListenersOperation(List<ExecutionListener> listeners) {\n            this.listeners = listeners;\n        }\n\n        @Override\n        public void execute(InterpretableExecution execution) {\n            for (ExecutionListener executionListener : listeners) {\n                try {\n                    Context.getProcessEngineConfiguration()\n                            .getDelegateInterceptor()\n                            .handleInvocation(new ExecutionListenerInvocation(executionListener, execution));\n                } catch (Exception e) {\n                    throw new ActivitiException(\"Couldn't execute listener\", e);\n                }\n            }\n        }\n\n        @Override\n        public boolean isAsync(InterpretableExecution execution) {\n            return false;\n        }\n\n    }\n}\n","sourceCodeStart":355,"sourceCodeEnd":385,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java#L355-L385","documentation":"Thrown by the anonymous ExecutionListener notifier inside MultiInstanceActivityBehavior.execute when invoking a registered execution listener through the DelegateInterceptor throws any Exception. The ActivitiException wraps the original cause, so the real error (NPE, expression failure, delegate misconfiguration) is in getCause().","triggerScenarios":"An ExecutionListener attached to the multi-instance activity (or its inner listener list) raises during execution: a classNotFoundException for the delegate class, an expression/UEL evaluation failure, or any runtime exception inside listener.notify().","commonSituations":"Delegate class not on the classpath or wrong package after refactoring; Spring bean referenced by delegateExpression not found; listener code throwing NPE because a process variable it depends on was never set.","solutions":["Inspect the wrapped cause (e.getCause()) to find the real listener failure","Fix the listener delegate: correct class name/bean reference in the BPMN and verify it is on the classpath / registered in the Spring context","Harden the listener to null-check the variables it reads, or set defaults before the multi-instance activity starts"],"exampleFix":"// before\n<activiti:executionListener event=\"start\" class=\"com.acme.OldListener\"/> <!-- class removed -->\n// after\n<activiti:executionListener event=\"start\" delegateExpression=\"${myListener}\"/> <!-- Spring bean present in app context -->","handlingStrategy":"try-catch","validationCode":"// before starting the process, verify listener classes/beans resolve\nClass.forName(\"com.acme.MyListener\"); // for class-based delegates\nassertTrue(appContext.containsBean(\"myListener\")); // for delegateExpression","typeGuard":null,"tryCatchPattern":"try {\n    runtimeService.startProcessInstanceByKey(\"myProcess\");\n} catch (org.activiti.engine.ActivitiException e) {\n    if (\"Couldn't execute listener\".equals(e.getMessage())) {\n        Throwable real = e.getCause(); // inspect the actual listener failure\n        log.error(\"Listener failed: {}\", real.getMessage(), real);\n    }\n}","preventionTips":["Always log/print the cause chain of ActivitiException - the message alone is generic","Keep listener delegates as Spring beans referenced via delegateExpression for easier DI/testing","Make listeners defensive: null-check variables, avoid throwing on missing data","Include listener classes in the deployment artifact and verify classpath at startup"],"tags":["bpmn","execution-listener","delegate-invocation","wrapped-exception"],"backgroundTag":"upstream-api-error","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}