{"record":{"id":"19caab897862e51e","repo":"flowable/flowable-engine","slug":"job-failed","errorCode":null,"errorMessage":"Job {} failed","messagePattern":"Job (.+?) failed","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/ExecuteJobsCmd.java","lineNumber":108,"sourceCode":"            if (commandContext.getEventDispatcher().isEnabled()) {\n                commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(\n                        FlowableEngineEventType.JOB_EXECUTION_SUCCESS, job), EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\n            }\n\n        } catch (Throwable exception) {\n            failedJobListener.setException(exception);\n\n            // Dispatch an event, indicating job execution failed in a try-catch block, to prevent the original\n            // exception to be swallowed\n            if (commandContext.getEventDispatcher().isEnabled()) {\n                try {\n                    commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(\n                            FlowableEngineEventType.JOB_EXECUTION_FAILURE, job, exception), EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\n                } catch (Throwable ignore) {\n                    LOGGER.warn(\"Exception occurred while dispatching job failure event, ignoring.\", ignore);\n                }\n            }\n\n            // Finally, Throw the exception to indicate the ExecuteJobCmd failed\n            if (!(exception instanceof ActivitiException)) {\n                throw new ActivitiException(\"Job \" + jobId + \" failed\", exception);\n            } else {\n                throw (ActivitiException) exception;\n            }\n        } finally {\n            if (jobExecutorContext != null) {\n                jobExecutorContext.setCurrentJob(null);\n            }\n        }\n        return null;\n    }\n\n    public String getJobId() {\n        return jobId;\n    }\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/ExecuteJobsCmd.java#L90-L126","documentation":"This is the generic wrapper ActivitiException thrown by ExecuteJobsCmd when asynchronous job execution fails with a non-Activiti exception. The original exception (whatever the job handler, delegate, or listener threw) is attached as the cause, and a JOB_EXECUTION_FAILURE event is dispatched to the event registry first. If the underlying failure was already an ActivitiException it is rethrown as-is; otherwise it is wrapped with the message 'Job <id> failed'.","triggerScenarios":"Any async job (timer, async continuation, message job) whose execution throws a checked/unexpected Throwable: a delegate class throwing a RuntimeException, a job handler misconfiguration, a classpath/serialization failure, or a database error during job execution. Raised in ExecuteJobsCmd.execute.","commonSituations":"JavaDelegate throwing NPEs or business exceptions; missing delegate class on the server classpath; job handler configuration referencing an unknown handler type; transient DB failures (lock contention, connection loss) during async execution; failed retries after max attempts in a job executor environment.","solutions":["Inspect the 'cause' of this exception — it contains the real failure from the job/delegate — and fix that root issue.","Review the ACT_GE_JOB / dead-letter job tables (or management service job queries) for the failed job, its exception stack trace and retry count.","Fix the delegate/handler code that threw, or handle business exceptions inside the delegate.","Redeploy/retry the job (JobRetriesServiceImpl or managementService retries) once the root cause is fixed; check job executor logs for repeated failures."],"exampleFix":"// before\nclass MyDelegate implements JavaDelegate {\n  public void execute(DelegateExecution e) {\n    throw new RuntimeException(\"config missing\");\n  }\n}\n// after\nclass MyDelegate implements JavaDelegate {\n  public void execute(DelegateExecution e) {\n    String cfg = (String) e.getVariable(\"config\");\n    if (cfg == null) {\n      throw new BpmnError(\"MISSING_CONFIG\", \"config variable missing\");\n    }\n  }\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  managementService.executeJob(jobId);\n} catch (ActivitiException e) {\n  Throwable root = e.getCause();\n  log.error(\"Job {} failed, root cause: {}\", jobId, root, root);\n  if (root instanceof BpmnError) {\n    // route to error handling / compensation\n  } else {\n    // inspect failed job retries via managementService.createJobQuery()\n  }\n}","preventionTips":["Always log/unwrap getCause() — the real failure is in the cause","Make delegates fail fast with BpmnError for business errors instead of raw RuntimeExceptions","Monitor dead-letter jobs and set sensible retry limits","Verify delegate classes and job handler types are on the server classpath before deployment"],"tags":["job-execution","async","exception-wrapper","flowable"],"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"}