flowable/flowable-engine · error · ActivitiException
Exception while invoking TaskListener
Error message
Exception while invoking TaskListener: %s
What it means
ClassDelegate.notify(DelegateTask) invokes the task listener through the configured DelegateInterceptor via TaskListenerInvocation. Any exception thrown inside the interceptor invocation or the listener itself is caught and rethrown as ActivitiException('Exception while invoking TaskListener: ...') with the original as cause.
Solutions
- Read the cause stack trace (e.getCause()) to find the real exception in your listener
- Fix the bug in the TaskListener implementation
- Wrap risky listener logic defensively and handle expected failures inside the listener
Defensive patterns
Strategy: try-catch
Try / catch
try {
taskService.complete(taskId);
} catch (org.activiti.engine.ActivitiException e) {
if (e.getMessage().startsWith("Exception while invoking TaskListener")) {
Throwable root = ExceptionUtils.getRootCause(e); // inspect the actual listener failure
}
} Prevention
- Wrap user listener code with its own try-catch and logging
- Test task listeners in isolation before deploying the process
- Avoid long-running/unreliable operations inside task listeners
When it happens
Trigger: A task listener event fires (create/assignment/complete) and the delegate's notify() throws, or the DelegateInterceptor.handleInvocation call fails.
Common situations: Null pointer inside user listener code; listener accessing missing variables or services; transaction/rollback problems inside the listener.
Related errors
- does not implement the nor the interface
- does not implement the interface
- completed() can only be called on a
- completed() can only be called on a…
- completing() can only be called on a
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/1f772d2434b081a4.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/bpmn/helper/ClassDelegate.java:125
} else if (delegateInstance instanceof JavaDelegate) {
return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance, skipExpression);
} else {
throw new ActivitiIllegalArgumentException(delegateInstance.getClass().getName() + " doesn't implement " + ExecutionListener.class + " nor " + JavaDelegate.class);
}
}
// Task listener
@Override
public void notify(DelegateTask delegateTask) {
if (taskListenerInstance == null) {
taskListenerInstance = getTaskListenerInstance();
}
try {
Context.getProcessEngineConfiguration()
.getDelegateInterceptor()
.handleInvocation(new TaskListenerInvocation(taskListenerInstance, delegateTask));
} catch (Exception e) {
throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
}
}
protected TaskListener getTaskListenerInstance() {
Object delegateInstance = instantiateDelegate(className, fieldDeclarations);
if (delegateInstance instanceof TaskListener) {
return (TaskListener) delegateInstance;
} else {
throw new ActivitiIllegalArgumentException(delegateInstance.getClass().getName() + " doesn't implement " + TaskListener.class);
}
}
// Activity Behavior
@Override
public void execute(DelegateExecution execution) {
ActivityExecution activityExecution = (ActivityExecution) execution;
if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {View on GitHub (pinned to d6d39ce1c6)