{"record":{"id":"d99e6071b7738d81","repo":"flowable/flowable-engine","slug":"no-job-found-with-id-jobid-d99e60","errorCode":null,"errorMessage":"No job found with id '${jobId}'","messagePattern":"No job found with id '(.+?)'","errorType":"exception","errorClass":"ActivitiObjectNotFoundException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteJobCmd.java","lineNumber":61,"sourceCode":"    @Override\r\n    public Object execute(CommandContext commandContext) {\r\n        JobEntity jobToDelete = getJobToDelete(commandContext);\r\n\r\n        jobToDelete.delete();\r\n        return null;\r\n    }\r\n\r\n    protected JobEntity getJobToDelete(CommandContext commandContext) {\r\n        if (jobId == null) {\r\n            throw new ActivitiIllegalArgumentException(\"jobId is null\");\r\n        }\r\n        if (LOGGER.isDebugEnabled()) {\r\n            LOGGER.debug(\"Deleting job {}\", jobId);\r\n        }\r\n\r\n        JobEntity job = commandContext.getJobEntityManager().findJobById(jobId);\r\n        if (job == null) {\r\n            throw new ActivitiObjectNotFoundException(\"No job found with id '\" + jobId + \"'\", Job.class);\r\n        }\r\n\r\n        // We need to check if the job was locked, ie acquired by the job acquisition thread\r\n        // This happens if the job was already acquired, but not yet executed.\r\n        // In that case, we can't allow to delete the job.\r\n        if (job.getLockOwner() != null) {\r\n            throw new ActivitiException(\"Cannot delete job when the job is being executed. Try again later.\");\r\n        }\r\n        return job;\r\n    }\r\n\r\n}\r\n","sourceCodeStart":43,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteJobCmd.java#L43-L74","documentation":"DeleteJobCmd looks up the job by id via JobEntityManager.findJobById. When no JobEntity exists for the given id, the command aborts with ActivitiObjectNotFoundException carrying the missing job id and the expected entity class (Job.class). This prevents deletion of a non-existent job and gives callers a typed not-found signal.","triggerScenarios":"Calling ManagementService.deleteJob(jobId), RuntimeService.deleteUserJob / deleteTimerJob, or any API that executes DeleteJobCmd, with a job id that does not exist (already deleted, wrong engine/database, or fabricated id).","commonSituations":"Deleting a job twice (e.g. after a failed async execution already removed it); pointing at a job id from another process definition instance or another Activiti/Flowable database; stale job ids cached in application code; job cleaned up by job executor timeout handling before manual delete.","solutions":["Verify the job id exists before deleting: ManagementService.createJobQuery(). jobId(id).singleResult() != null","Check you are connected to the correct database/engine where the job was created","Wrap deleteJob in a try-catch for ActivitiObjectNotFoundException and treat it as already-deleted/idempotent","Re-check application logic that produced the id (e.g. using a processInstanceId instead of jobId)"],"exampleFix":"// before\nmanagementService.deleteJob(jobId);\n// after\nJob job = managementService.createJobQuery().jobId(jobId).singleResult();\nif (job != null) {\n    managementService.deleteJob(jobId);\n}","handlingStrategy":"try-catch","validationCode":"Job job = managementService.createJobQuery().jobId(jobId).singleResult();\nif (job == null) { /* skip: job already gone */ }","typeGuard":"if (jobId != null && managementService.createJobQuery().jobId(jobId).singleResult() != null) { /* safe to delete */ }","tryCatchPattern":"try {\n    managementService.deleteJob(jobId);\n} catch (ActivitiObjectNotFoundException e) {\n    log.info(\"Job {} already deleted\", jobId);\n}","preventionTips":["Query the job before deleting","Treat not-found on delete as idempotent success","Confirm engine/database consistency across environments"],"tags":["job","not-found","process-engine","activiti"],"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"}