{"record":{"id":"a9d49dc495db9b68","repo":"flowable/flowable-engine","slug":"no-job-found-with-id-a9d49d","errorCode":null,"errorMessage":"No job found with id ","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/GetJobExceptionStacktraceCmd.java","lineNumber":48,"sourceCode":"    private static final long serialVersionUID = 1L;\n    private String jobId;\n\n    public GetJobExceptionStacktraceCmd(String jobId) {\n        this.jobId = jobId;\n    }\n\n    @Override\n    public String execute(CommandContext commandContext) {\n        if (jobId == null) {\n            throw new ActivitiIllegalArgumentException(\"jobId is null\");\n        }\n\n        JobEntity job = commandContext\n                .getJobEntityManager()\n                .findJobById(jobId);\n\n        if (job == null) {\n            throw new ActivitiObjectNotFoundException(\"No job found with id \" + jobId, Job.class);\n        }\n\n        return job.getExceptionStacktrace();\n    }\n\n}\n","sourceCodeStart":30,"sourceCodeEnd":55,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/GetJobExceptionStacktraceCmd.java#L30-L55","documentation":"After the null check, GetJobExceptionStacktraceCmd loads the job by id. If no job with that id exists it throws ActivitiObjectNotFoundException('No job found with id ' + jobId, Job.class), because there is no stored stacktrace to return.","triggerScenarios":"Calling ManagementService.getJobExceptionStacktrace(id) for a job that was already executed and deleted, a wrong id, or querying the wrong job table (timer job vs async job vs suspended job in some versions).","commonSituations":"Job executed successfully between listing it and fetching its stacktrace (only failed jobs retain stacktraces); stale ids after restart/cleanup; looking up a timer job via the plain job API.","solutions":["Confirm the job exists and is failed: managementService.createJobQuery().jobId(id).singleResult() and check getExceptionByteArrayRef/getRetries","Catch ActivitiObjectNotFoundException and treat it as 'no stacktrace for this job'","Get fresh job ids from managementService.createJobQuery().withException().list() before fetching stacktraces","If using timers, use the appropriate job/timer query or API variant"],"exampleFix":"// before\nString st = managementService.getJobExceptionStacktrace(jobId);\n// after\nJob job = managementService.createJobQuery().jobId(jobId).singleResult();\nif (job != null && job.getRetries() <= 0) {\n    String st = managementService.getJobExceptionStacktrace(jobId);\n}","handlingStrategy":"try-catch","validationCode":"boolean jobExists = managementService.createJobQuery().jobId(jobId).count() > 0;","typeGuard":"boolean jobExists(String jobId) {\n    return jobId != null && managementService.createJobQuery().jobId(jobId).count() > 0;\n}","tryCatchPattern":"try {\n    String st = managementService.getJobExceptionStacktrace(jobId);\n} catch (ActivitiObjectNotFoundException e) {\n    // job executed/removed: no stacktrace available\n}","preventionTips":["Fetch stacktraces promptly after detecting a failed job; successful jobs are deleted","Re-query jobs instead of caching ids across transactions/restarts","Filter with .withException() to target only failed jobs"],"tags":["flowable","activiti","not-found","job","stacktrace"],"backgroundTag":"resource-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"}