{"record":{"id":"f56877a8cf137e76","repo":"flowable/flowable-engine","slug":"couldn-t-execute-activity-type-id-activityi","errorCode":null,"errorMessage":"couldn't execute activity <${type} id=\"${activityId}\" ...>: ","messagePattern":"couldn't execute activity <(.+?) id=\"(.+?)\" \\.\\.\\.>: ","errorType":"exception","errorClass":"ActivitiActivityExecutionException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/AtomicOperationActivityExecute.java","lineNumber":71,"sourceCode":"                Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(\n                        ActivitiEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_STARTED,\n                                execution.getActivity().getId(),\n                                (String) execution.getActivity().getProperty(\"name\"),\n                                execution.getId(),\n                                execution.getProcessInstanceId(),\n                                execution.getProcessDefinitionId(),\n                                (String) activity.getProperties().get(\"type\"),\n                                activity.getActivityBehavior().getClass().getCanonicalName()),\n                        EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG);\n            }\n\n            activityBehavior.execute(execution);\n\n        } catch (ActivitiException e) {\n            throw e;\n        } catch (Throwable t) {\n            LogMDC.putMDCExecution(execution);\n            throw new ActivitiActivityExecutionException(\"couldn't execute activity <\" + activity.getProperty(\"type\") + \" id=\\\"\" + activity.getId() + \"\\\" ...>: \" + t.getMessage(), t);\n        }\n    }\n}\n","sourceCodeStart":53,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/AtomicOperationActivityExecute.java#L53-L75","documentation":"This error wraps any Throwable thrown by an activity's Behavior.execute() during process execution in the Flowable/Activiti PVM. The engine re-wraps non-Activiti exceptions into an ActivitiActivityExecutionException prefixed with the activity type and id so the failing process node can be identified. The original cause is preserved as the exception cause.","triggerScenarios":"Any RuntimeException or checked Throwable thrown from inside a custom ActivityBehavior's execute(execution) method while the PVM atomic operation ACTIVITY_EXECUTE runs the node (e.g. a delegate throwing NPE, a service task delegate class failing, a checked exception from business logic).","commonSituations":"Custom JavaDelegate or ActivityBehavior code throwing NPE due to missing process variables; misconfigured service-task class names causing instantiation failures; database/network calls inside delegates failing; switching Activiti versions where a behavior API changed.","solutions":["Read the cause chain of the ActivitiActivityExecutionException to find the real exception from the behavior code","Check the activity id/type in the message and inspect that node's behavior/delegate implementation","Fix or guard the failing code in the ActivityBehavior.execute() implementation","Add process variables null-checks inside the delegate before use"],"exampleFix":"// before\npublic void execute(DelegateExecution exec) {\n  String url = (String) exec.getVariable(\"url\");\n  http.get(url); // NPE if variable missing\n}\n// after\npublic void execute(DelegateExecution exec) {\n  String url = (String) exec.getVariable(\"url\");\n  if (url == null) throw new ActivitiException(\"url variable required\");\n  http.get(url);\n}","handlingStrategy":"try-catch","validationCode":"// before starting the process instance\nif (processVariables.get(\"url\") == null) {\n  throw new IllegalArgumentException(\"required process variable 'url' is missing\");\n}","typeGuard":"// Java: check delegate field before use\nif (!(execution.getVariable(\"count\") instanceof Integer)) {\n  throw new ActivitiException(\"'count' must be an Integer\");\n}","tryCatchPattern":"try {\n  runtimeService.startProcessInstanceByKey(key, vars);\n} catch (ActivitiActivityExecutionException e) {\n  log.error(\"activity {} failed\", e.getActivityId(), e.getCause()); // inspect cause\n}","preventionTips":["Always null-check process variables inside delegates","Unit-test each ActivityBehavior in isolation","Keep checked exceptions wrapped inside behaviors","Log the cause chain, not just the wrapper message"],"tags":["process-engine","activity-execution","wrapped-exception"],"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-18T11:17:12.947Z"}