{"record":{"id":"59471c04afcdd052","repo":"flowable/flowable-engine","slug":"no-job-found-with-id","errorCode":null,"errorMessage":"No job found with id '","messagePattern":"No job found with id '","errorType":"exception","errorClass":"FlowableObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/DeleteJobCmd.java","lineNumber":85,"sourceCode":"    protected void sendCancelEvent(JobEntity jobToDelete) {\n        FlowableEventDispatcher eventDispatcher = jobServiceConfiguration.getEventDispatcher();\n        if (eventDispatcher != null && eventDispatcher.isEnabled()) {\n            eventDispatcher.dispatchEvent(FlowableJobEventBuilder.createEntityEvent(FlowableEngineEventType.JOB_CANCELED, jobToDelete),\n                    jobServiceConfiguration.getEngineName());\n        }\n    }\n\n    protected JobEntity getJobToDelete(CommandContext commandContext) {\n        if (jobId == null) {\n            throw new FlowableIllegalArgumentException(\"jobId is null\");\n        }\n        if (LOGGER.isDebugEnabled()) {\n            LOGGER.debug(\"Deleting job {}\", jobId);\n        }\n\n        JobEntity job = jobServiceConfiguration.getJobEntityManager().findById(jobId);\n        if (job == null) {\n            throw new FlowableObjectNotFoundException(\"No job found with id '\" + jobId + \"'\", Job.class);\n        }\n\n        // We need to check if the job was locked, ie acquired by the job acquisition thread\n        // This happens if the job was already acquired, but not yet executed.\n        // In that case, we can't allow to delete the job.\n        if (job.getLockOwner() != null) {\n            throw new FlowableException(\"Cannot delete \" + job + \" when the job is being executed. Try again later.\");\n        }\n        return job;\n    }\n\n}\n","sourceCodeStart":67,"sourceCodeEnd":98,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/cmd/DeleteJobCmd.java#L67-L98","documentation":"DeleteJobCmd loads the job via JobEntityManager.findById and throws FlowableObjectNotFoundException(\"No job found with id '...'\") referencing Job.class when no job entity matches. The id is absent from ACT_RU_JOB (timer/message/async jobs) at delete time.","triggerScenarios":"managementService.deleteJob(id) for a job that was already executed by the async executor, a typo'd id, or an id belonging to another job table (timer suspended, dead letter, external worker, history job).","commonSituations":"Race between user-driven cleanup and the async job executor consuming the job; canceling a process instance already removed its jobs; deleting timer jobs that fired and were deleted on completion; multi-engine/multi-schema confusion.","solutions":["Check existence first with managementService.createJobQuery().jobId(id).count() > 0 and delete only when found.","Catch FlowableObjectNotFoundException and treat as already-deleted in cleanup/cancel code.","Use the correct manager/table for the job kind (suspended, dead letter, timer, external worker, history) — a plain DeleteJobCmd only sees ACT_RU_JOB.","Verify the engine and database the id was issued from match the one performing the delete."],"exampleFix":"// before\nmanagementService.deleteJob(timerJobId);\n// after\nif (managementService.createJobQuery().jobId(timerJobId).count() > 0) {\n    managementService.deleteJob(timerJobId);\n}","handlingStrategy":"validation","validationCode":"Job job = managementService.createJobQuery().jobId(jobId).singleResult();\nif (job == null) {\n    LOGGER.info(\"Job {} does not exist; nothing to delete\", jobId);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    managementService.deleteJob(jobId);\n} catch (FlowableObjectNotFoundException e) {\n    LOGGER.info(\"Job {} already deleted or never existed\", jobId);\n}","preventionTips":["Use the matching query/table for the job kind you intend to delete.","Assume the async executor may delete jobs concurrently.","Keep engine name and database consistent between writer and deleter."],"tags":["flowable","job-management","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}