flowable/flowable-engine · error · FlowableException

Could not resolve key from expression:

Error message

Could not resolve key from expression: 

What it means

EventRegistryEventListenerActivityBehaviour needs an event definition key to register an event registry event for the plan item. The key may come from the static eventDefinitionKey or an eventDefinitionKeyExpression. If both yield null, the engine cannot resolve which event definition to subscribe to and throws this FlowableException in resolveEventDefinitionKey.

Source

Thrown at modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/EventRegistryEventListenerActivityBehaviour.java:74

    public EventRegistryEventListenerActivityBehaviour(Expression eventDefinitionKeyExpression) {
        this.eventDefinitionKeyExpression = eventDefinitionKeyExpression;
    }

    @Override
    public void execute(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity) {

    }

    protected String resolveEventDefinitionKey(PlanItemInstanceEntity planItemInstanceEntity) {
        Object key = null;

        if (eventDefinitionKeyExpression != null) {
            key = eventDefinitionKeyExpression.getValue(planItemInstanceEntity);
        }

        if (key == null) {
            throw new FlowableException("Could not resolve key from expression: " + eventDefinitionKeyExpression + " for " + planItemInstanceEntity);
        }

        return key.toString();
    }

    @Override
    public void trigger(CommandContext commandContext, PlanItemInstanceEntity planItemInstanceEntity) {
        EventInstance eventInstance = (EventInstance) planItemInstanceEntity.getTransientVariable(EventConstants.EVENT_INSTANCE);
        if (eventInstance != null) {
            handleEventInstance(planItemInstanceEntity, eventInstance, commandContext);
        }
        
        RepetitionRule repetitionRule = ExpressionUtil.getRepetitionRule(planItemInstanceEntity);
        if (repetitionRule != null && ExpressionUtil.evaluateRepetitionRule(commandContext, planItemInstanceEntity, planItemInstanceEntity.getStagePlanItemInstanceEntity())) {
            PlanItemInstanceEntity eventPlanItemInstanceEntity = PlanItemInstanceUtil.copyAndInsertPlanItemInstance(commandContext, planItemInstanceEntity, false, false);
            CmmnEngineAgenda agenda = CommandContextUtil.getAgenda(commandContext);
            agenda.planCreatePlanItemInstanceWithoutEvaluationOperation(eventPlanItemInstanceEntity);
            agenda.planOccurPlanItemInstanceOperation(eventPlanItemInstanceEntity);

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Set the event definition key variable in case scope before the listener plan item activates.
  2. Configure a static eventDefinitionKey on the event listener element in the CMMN XML if the key is known at design time.
  3. Fix the expression so it points at an existing, populated variable.
  4. Ensure the event definition with that key is registered in the event registry (separate lookup error would otherwise follow).

Example fix

// before
<eventRegistryEventListener eventDefinitionKeyExpression="${evtKey}"/> ... case variable "eventKey" set -> typo -> null
// after
caseRuntimeService.setVariable(caseInstanceId, "evtKey", "myEventDefinition");
Defensive patterns

Strategy: validation

Validate before calling

Object key = caseVariables.get("eventKey");
if (key == null || key.toString().isBlank()) {
    throw new IllegalArgumentException("eventKey variable must be set before event listener activates");
}

Type guard

if (keyValue instanceof String s && !s.isEmpty()) { /* usable as event definition key */ }

Try / catch

try {
    caseRuntimeService.triggerPlanItemInstance(planItemId);
} catch (FlowableException e) {
    if (e.getMessage().startsWith("Could not resolve key from expression")) {
        log.error("Event definition key expression unresolved on case {}", caseInstanceId);
    }
    throw e;
}

Prevention

When it happens

Trigger: An event registry event listener plan item whose event definition key expression (e.g. ${eventKey}) evaluates to null when the plan item activates, and no static key is configured.

Common situations: Case variable holding the event key never set; expression typo; event definition key attribute left blank in the case model; variable set after the listener already activated.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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