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

  1. Read the cause stack trace (e.getCause()) to find the real exception in your listener
  2. Fix the bug in the TaskListener implementation
  3. 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

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


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)