flowable/flowable-engine · error · FlowableIllegalArgumentException

Entity cannot be null.

Error message

Entity cannot be null.

What it means

FlowableEntityEventImpl represents an engine entity event and requires a non-null entity. The constructor validates the entity argument and throws FlowableIllegalArgumentException immediately if it is null, since an entity event without an entity is meaningless.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/delegate/event/impl/FlowableEntityEventImpl.java:32

import org.flowable.common.engine.api.FlowableIllegalArgumentException;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;

/**
 * Base class for all {@link FlowableEvent} implementations, related to entities.
 * 
 * @author Frederik Heremans
 */
public class FlowableEntityEventImpl extends FlowableProcessEventImpl implements FlowableEngineEntityEvent {

    protected Object entity;

    public FlowableEntityEventImpl(Object entity, FlowableEngineEventType type) {
        super(type);
        if (entity == null) {
            throw new FlowableIllegalArgumentException("Entity cannot be null.");
        }
        this.entity = entity;
    }

    @Override
    public Object getEntity() {
        return entity;
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Ensure the entity object is fully loaded and non-null before constructing the event
  2. Add a null check upstream and skip event dispatch when the entity is absent
  3. Catch FlowableIllegalArgumentException around custom event construction during development

Example fix

// before
dispatcher.dispatchEvent(new FlowableEntityEventImpl(entity, type));
// after
if (entity != null) {
    dispatcher.dispatchEvent(new FlowableEntityEventImpl(entity, type));
}
Defensive patterns

Strategy: validation

Validate before calling

if (entity == null) { throw new IllegalArgumentException("entity required before dispatching entity event"); }

Type guard

boolean canDispatch = entity != null;

Try / catch

try { new FlowableEntityEventImpl(entity, type); } catch (FlowableIllegalArgumentException e) { log.warn("skipped event: no entity"); }

Prevention

When it happens

Trigger: Programmatically constructing new FlowableEntityEventImpl(null, type) — e.g. custom event dispatch code or engine-internal event creation with a null entity object.

Common situations: Custom FlowableEventListener / event builder code that passes a null entity; refactors where the entity lookup returned null before event creation.

Related errors


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