flowable/flowable-engine · error · FlowableException

Unexpected activity type found for " + job + " at " + execut

Error message

Unexpected activity type found for " + job + " at " + executionEntity

What it means

Thrown by AsyncSendEventJobHandler.execute when the async job's execution's current flow element is not a SendEventServiceTask. The handler only knows how to drive SendEvent activity behavior, so any other element type indicates internal state corruption.

Source

Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java:44

 *
 * @author Tijs Rademakers
 */
public class AsyncSendEventJobHandler implements JobHandler {

    public static final String TYPE = "async-send-event";

    @Override
    public String getType() {
        return TYPE;
    }

    @Override
    public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {
        ExecutionEntity executionEntity = (ExecutionEntity) variableScope;
        FlowElement flowElement = executionEntity.getCurrentFlowElement();

        if (!(flowElement instanceof SendEventServiceTask)) {
            throw new FlowableException("Unexpected activity type found for " + job + " at " + executionEntity);
        }

        Object behavior = ((SendEventServiceTask) flowElement).getBehavior();
        if (!(behavior instanceof ActivityBehavior activityBehavior)) {
            throw new FlowableException(
                    "Unexpected activity behavior (" + behavior.getClass() + ") found for " + job + " at " + executionEntity);
        }

        try {
            commandContext.addAttribute(TYPE, true); // Will be read in the SendEventTaskActivityBehavior
            activityBehavior.execute(executionEntity);
        } finally {
            commandContext.removeAttribute(TYPE);
        }
    }

}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Verify the job's process definition was deployed by a compatible Flowable version (BPMN model still contains the SendEventServiceTask)
  2. Recreate the job/restart the process instance to resync execution state
  3. Check for custom code or migrations that altered executions or job configuration
Defensive patterns

Strategy: try-catch

Try / catch

try { jobExecutorJob.run(); } catch (FlowableException e) { if (e.getMessage().startsWith("Unexpected activity type")) { /* resync/recreate job, flag process instance for review */ } else throw e; }

Prevention

When it happens

Trigger: An async send-event job executing against an execution whose currentFlowElement is not a SendEventServiceTask — typically after job/execution state desync, engine version mismatch, or manual job manipulation.

Common situations: Upgrading engines over in-flight jobs, database records altered by async executor retries across schema versions, or custom code moving executions between activities without updating jobs.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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