{"record":{"id":"541a473c535fe0ce","repo":"flowable/flowable-engine","slug":"no-execution-context-active-and-event-event","errorCode":null,"errorMessage":"No execution context active and event (\" + event + \") is not related to an execution. No compensation event can be thrown.","messagePattern":"No execution context active and event \\(\" \\+ event \\+ \"\\) is not related to an execution\\. No compensation event can be thrown\\.","errorType":"exception","errorClass":"FlowableException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java","lineNumber":58,"sourceCode":"            CommandContext commandContext = Context.getCommandContext();\n\n            if (engineEvent.getProcessDefinitionId() != null &&\n                    Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, engineEvent.getProcessDefinitionId())) {\n\n                Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();\n                compatibilityHandler.throwErrorEvent(event);\n                return;\n            }\n\n            ExecutionEntity execution = null;\n\n            if (engineEvent.getExecutionId() != null) {\n                // Get the execution based on the event's execution ID instead\n                execution = CommandContextUtil.getExecutionEntityManager().findById(engineEvent.getExecutionId());\n            }\n\n            if (execution == null) {\n                throw new FlowableException(\"No execution context active and event (\" + event + \") is not related to an execution. No compensation event can be thrown.\");\n            }\n\n            try {\n                ErrorPropagation.propagateError(errorCode, execution);\n            } catch (Exception e) {\n                throw new FlowableException(\"Error while propagating error-event for \" + execution, e);\n            }\n        }\n    }\n\n    public void setErrorCode(String errorCode) {\n        this.errorCode = errorCode;\n    }\n\n    @Override\n    public boolean isFailOnException() {\n        return true;\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/helper/ErrorThrowingEventListener.java#L40-L76","documentation":"ErrorThrowingEventListener.onEvent throws this FlowableException when it needs to propagate a BPMN error (compensation) but cannot resolve any Execution to act on: neither the event's executionId resolved to an existing execution nor was a default execution available. Error propagation (ErrorPropagation.propagateError) requires an execution context, so the listener aborts.","triggerScenarios":"A FlowableEventListener of type 'error' with an errorCode is dispatched an event whose getExecutionId() is null (or whose execution entity no longer exists) while isErrorPropagationEnabled, so propagateError has no target execution.","commonSituations":"Listening to global/engine-level events (e.g. via a global event listener registered for all events) that are not tied to a process execution, such as job- or engine-level events; stale execution IDs after async job completion or process-end cleanup; misconfigured listener attached to the wrong event type.","solutions":["Register the error-throwing listener only for events that carry an executionId (activity-level listeners on a BPMN element, or filter event types in the dispatcher).","Check FlowableEvent.getExecutionId() before configuring the listener to throw; skip/ignore events with null executionId in your own wrapping listener.","Verify the execution still exists when the event fires (e.g. not after process end); if handling process-end events, propagate the error before the execution terminates.","If the intent is compensation rather than error propagation, use a compensation-event listener with a valid scope execution instead."],"exampleFix":"// before\nglobalEventListener.onEvent(anyFlowableEvent); // may have executionId == null\n\n// after\nif (flowableEvent instanceof FlowableEngineEvent e && e.getExecutionId() != null) {\n    errorThrowingEventListener.onEvent(flowableEvent);\n}","handlingStrategy":"validation","validationCode":"// before dispatching to the listener\nif (!(event instanceof FlowableEngineEvent) || ((FlowableEngineEvent) event).getExecutionId() == null) {\n    return; // skip error propagation for execution-less events\n}","typeGuard":"static boolean hasExecution(FlowableEvent event) {\n    return event instanceof FlowableEngineEvent && ((FlowableEngineEvent) event).getExecutionId() != null;\n}","tryCatchPattern":null,"preventionTips":["Bind error-throwing listeners to activity-level BPMN elements, not global engine event dispatch.","Filter event types in listener registration to those guaranteed to carry an executionId.","Never propagate BPMN errors from process-end or engine-lifecycle events."],"tags":["flowable","bpmn","event-listener","error-propagation","missing-execution"],"backgroundTag":"missing-required-argument","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"}