{"record":{"id":"242e93f051aee062","repo":"flowable/flowable-engine","slug":"cannot-find-task-with-id-taskid","errorCode":null,"errorMessage":"Cannot find task with id ${taskId}","messagePattern":"Cannot find task with id (.+?)","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":404,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/ActivateTaskCmd.java","lineNumber":54,"sourceCode":"    protected String userId;\n\n    public ActivateTaskCmd(String taskId, String userId) {\n        this.taskId = taskId;\n        this.userId = userId;\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        \n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n\n        TaskEntity task = cmmnEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);\n\n        if (task == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find task with id \" + taskId, Task.class);\n        }\n\n        if (task.isDeleted()) {\n            throw new FlowableException(\"Task \" + taskId + \" is already deleted\");\n        }\n\n        if (!task.isSuspended()) {\n            throw new FlowableException(\"Task \" + taskId + \" is not suspended, so can't be activated\");\n        }\n        \n        Clock clock = cmmnEngineConfiguration.getClock();\n        Date updateTime = clock.getCurrentTime();\n        task.setSuspendedTime(null);\n        task.setSuspendedBy(null);\n        if (task.getInProgressStartTime() != null) {\n            task.setState(Task.IN_PROGRESS);\n        } else if (task.getClaimTime() != null) {\n            task.setState(Task.CLAIMED);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/ActivateTaskCmd.java#L36-L72","documentation":"FlowableObjectNotFoundException thrown by ActivateTaskCmd.execute when the TaskService lookup getTask(taskId) returns null. The task id was provided but no TaskEntity exists with that id in the runtime task tables, so the command cannot activate it.","triggerScenarios":"Activating a task whose id was deleted (task completed or case terminated); using a stale id cached from a previous query; id from another engine/database (BPMN vs CMMN task tables); typo or truncated id.","commonSituations":"After case completion the runtime task rows are removed and old ids 404; retrying an activation job with an old id; environment mismatch (test id used against prod database).","solutions":["Query taskService.createTaskQuery().taskId(id).singleResult() first to confirm the task exists and is suspended","If the task is gone, treat the activation as obsolete and skip/log rather than retry","Verify the id against the Flowable admin UI or ACT_RU_TASK table","Confirm you are connected to the same database/engine where the task was created"],"exampleFix":"// before\ncmmnTaskService.activateTask(taskId); // may throw not-found\n// after\nTask task = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (task != null && task.isSuspended()) {\n    cmmnTaskService.activateTask(taskId);\n} else {\n    logger.info(\"Task {} missing or not suspended; skipping activation\", taskId);\n}","handlingStrategy":"validation","validationCode":"Task t = taskService.createTaskQuery().taskId(taskId).singleResult();\nif (t == null) throw new IllegalStateException(\"Task \" + taskId + \" does not exist\");","typeGuard":null,"tryCatchPattern":"try { cmmnTaskService.activateTask(taskId); }\ncatch (FlowableObjectNotFoundException e) { log.info(\"Task {} not found; likely already completed\", taskId); }","preventionTips":["Query the task before activation and skip missing ones","Purge stale task ids from work queues when cases finish","Confirm engine/database alignment before reusing ids across environments","Handle not-found as a benign, idempotent outcome in retry loops"],"tags":["flowable","cmmn","task","not-found"],"backgroundTag":"entity-not-found","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"}