flowable/flowable-engine · error · FlowableIllegalArgumentException

The event to be dispatched must not be null.

Error message

The event to be dispatched must not be null.

What it means

FlowableIllegalArgumentException thrown by DispatchEventCommand.execute when the FlowableEvent to dispatch is null. The command exists solely to push a platform event through the event dispatcher, so a null event is a programming error caught up front.

Solutions

  1. Ensure the FlowableEvent instance is built (e.g. FlowableCaseInstanceEventBuilder/FlowableEventBuilder) before dispatching
  2. Null-check the event before invoking dispatch
  3. Return early if your own event-producing code produced nothing

Example fix

// before
runtimeService.dispatchEvent(event);
// after
if (event != null) {
    runtimeService.dispatchEvent(event);
}
Defensive patterns

Strategy: validation

Validate before calling

if (event == null) throw new IllegalArgumentException("event required");

Type guard

boolean canDispatch = event instanceof FlowableEvent;

Try / catch

try { dispatcher.dispatchEvent(event, key); } catch (FlowableIllegalArgumentException e) { log.error("null event supplied", e); }

Prevention

When it happens

Trigger: Calling cmmnEngineConfiguration.getEventDispatcher() wrappers / dispatchEvent(null) or constructing new DispatchEventCommand(null).

Common situations: Event factory returned null (e.g. builder misused); variable holding the event never initialized; passing the result of a lookup that found no matching event object.

Related errors


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

Appendix: source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/DispatchEventCommand.java:40

import org.flowable.common.engine.impl.interceptor.CommandContext;

/**
 * This command dispatches an event within the case engine.
 *
 * @author Micha Kiener
 */
public class DispatchEventCommand implements Command<Void> {

    protected FlowableEvent event;

    public DispatchEventCommand(FlowableEvent event) {
        this.event = event;
    }

    @Override
    public Void execute(CommandContext commandContext) {
        if (event == null) {
            throw new FlowableIllegalArgumentException("The event to be dispatched must not be null.");
        }

        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);
        FlowableEventDispatcher eventDispatcher = cmmnEngineConfiguration.getEventDispatcher();
        if (eventDispatcher != null && eventDispatcher.isEnabled()) {
            eventDispatcher.dispatchEvent(event, cmmnEngineConfiguration.getEngineCfgKey());
        } else {
            throw new FlowableException("Message dispatcher is disabled, cannot dispatch event.");
        }

        return null;
    }
}

View on GitHub (pinned to d6d39ce1c6)