flowable/flowable-engine · error · ActivitiException
Couldn't execute listener
Error message
Couldn't execute listener
What it means
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().
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
Example fix
// before
<activiti:executionListener event="start" class="com.acme.OldListener"/> <!-- class removed -->
// after
<activiti:executionListener event="start" delegateExpression="${myListener}"/> <!-- Spring bean present in app context --> Defensive patterns
Strategy: try-catch
Validate before calling
// before starting the process, verify listener classes/beans resolve
Class.forName("com.acme.MyListener"); // for class-based delegates
assertTrue(appContext.containsBean("myListener")); // for delegateExpression Try / catch
try {
runtimeService.startProcessInstanceByKey("myProcess");
} catch (org.activiti.engine.ActivitiException e) {
if ("Couldn't execute listener".equals(e.getMessage())) {
Throwable real = e.getCause(); // inspect the actual listener failure
log.error("Listener failed: {}", real.getMessage(), real);
}
} Prevention
- 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
When it happens
Trigger: 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().
Common situations: 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.
Related errors
- Cannot create 'script' type execution listener. Missing…
- Could not execute inner activity behavior of multi instance…
- couldn't execute event listener :
- couldn't execute event listener :
- Delegate expression " + expression + " did not resolve to…
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/fc2c6a9ab0b97e01.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java:373
* @author Joram Barrez
*/
private static final class CallActivityListenersOperation implements AtomicOperation {
private List<ExecutionListener> listeners;
private CallActivityListenersOperation(List<ExecutionListener> listeners) {
this.listeners = listeners;
}
@Override
public void execute(InterpretableExecution execution) {
for (ExecutionListener executionListener : listeners) {
try {
Context.getProcessEngineConfiguration()
.getDelegateInterceptor()
.handleInvocation(new ExecutionListenerInvocation(executionListener, execution));
} catch (Exception e) {
throw new ActivitiException("Couldn't execute listener", e);
}
}
}
@Override
public boolean isAsync(InterpretableExecution execution) {
return false;
}
}
}
View on GitHub (pinned to d6d39ce1c6)