{"record":{"id":"934b84270257d9bb","repo":"flowable/flowable-engine","slug":"unexpected-activity-type-found-for-job-at","errorCode":null,"errorMessage":"Unexpected activity type found for \" + job + \" at \" + executionEntity","messagePattern":"Unexpected activity type found for \" \\+ job \\+ \" at \" \\+ executionEntity","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java","lineNumber":44,"sourceCode":" *\n * @author Tijs Rademakers\n */\npublic class AsyncSendEventJobHandler implements JobHandler {\n\n    public static final String TYPE = \"async-send-event\";\n\n    @Override\n    public String getType() {\n        return TYPE;\n    }\n\n    @Override\n    public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) {\n        ExecutionEntity executionEntity = (ExecutionEntity) variableScope;\n        FlowElement flowElement = executionEntity.getCurrentFlowElement();\n\n        if (!(flowElement instanceof SendEventServiceTask)) {\n            throw new FlowableException(\"Unexpected activity type found for \" + job + \" at \" + executionEntity);\n        }\n\n        Object behavior = ((SendEventServiceTask) flowElement).getBehavior();\n        if (!(behavior instanceof ActivityBehavior activityBehavior)) {\n            throw new FlowableException(\n                    \"Unexpected activity behavior (\" + behavior.getClass() + \") found for \" + job + \" at \" + executionEntity);\n        }\n\n        try {\n            commandContext.addAttribute(TYPE, true); // Will be read in the SendEventTaskActivityBehavior\n            activityBehavior.execute(executionEntity);\n        } finally {\n            commandContext.removeAttribute(TYPE);\n        }\n    }\n\n}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/jobexecutor/AsyncSendEventJobHandler.java#L26-L62","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the job's process definition was deployed by a compatible Flowable version (BPMN model still contains the SendEventServiceTask)","Recreate the job/restart the process instance to resync execution state","Check for custom code or migrations that altered executions or job configuration"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { jobExecutorJob.run(); } catch (FlowableException e) { if (e.getMessage().startsWith(\"Unexpected activity type\")) { /* resync/recreate job, flag process instance for review */ } else throw e; }","preventionTips":["Avoid hand-editing ACT_RU_JOB rows","Keep engine and model versions consistent across upgrades"],"tags":["flowable","job-executor","async","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}