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
- Ensure the entity object is fully loaded and non-null before constructing the event
- Add a null check upstream and skip event dispatch when the entity is absent
- 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
- Never construct entity events from possibly-null lookups
- Use Objects.requireNonNull with a clear message at event-factory boundaries
- Skip event dispatch when the entity could not be resolved
- Test event factories with null-entity paths
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.