flowable/flowable-engine · error · ActivitiIllegalArgumentException

listener is null.

Error message

listener is null.

What it means

RemoveEventListenerCommand.validate/addEventListener dispatch removes an event listener from the engine's event dispatcher, but requires the listener reference to be non-null; a null argument raises ActivitiIllegalArgumentException. Because listeners are removed by object identity, a null (or non-registered) reference is meaningless here.

Solutions

  1. Pass the same listener instance that was passed to addEventListener; keep a strong reference to it for the removal call.
  2. Fix dependency injection so the listener bean is populated (component scan, @Autowired, constructor injection).
  3. Null-check before calling removeEventListener and skip/log if the listener was never registered.

Example fix

// before
runtimeService.removeEventListener(listener);

// after
if (listener != null) {
    runtimeService.removeEventListener(listener);
}
Defensive patterns

Strategy: type-guard

Validate before calling

if (listener == null) { log.warn("no listener to remove"); return; }

Type guard

boolean canRemove(ActivitiEventListener l) { return l != null; }

Try / catch

try {
    runtimeService.removeEventListener(listener);
} catch (ActivitiIllegalArgumentException e) {
    log.warn("Listener was null, skipping removal");
}

Prevention

When it happens

Trigger: Calling runtimeService.removeEventListener(null) — typically because the listener variable was never assigned, a @Autowired field was null in a non-Spring-managed class, or the listener instance was reconstructed instead of keeping the originally registered object.

Common situations: Spring wiring misconfiguration so the listener field is null; deserialization/config reload recreating a new listener object instead of the registered instance; null default in plugin initialization code.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/cbd02cf33297ecba. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/RemoveEventListenerCommand.java:37

/**
 * Command that removes an event-listener to the Activiti engine.
 * 
 * @author Frederik Heremans
 */
public class RemoveEventListenerCommand implements Command<Void> {

    protected FlowableEventListener listener;

    public RemoveEventListenerCommand(FlowableEventListener listener) {
        super();
        this.listener = listener;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (listener == null) {
            throw new ActivitiIllegalArgumentException("listener is null.");
        }

        commandContext.getProcessEngineConfiguration()
                .getEventDispatcher().removeEventListener(listener);

        return null;
    }

}

View on GitHub (pinned to d6d39ce1c6)