{"record":{"id":"31936c7366bb6e73","repo":"Activiti/Activiti","slug":"could-not-execute-shell-command","errorCode":null,"errorMessage":"Could not execute shell command ","messagePattern":"Could not execute shell command ","errorType":"exception","errorClass":"ActivitiException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/ShellActivityBehavior.java","lineNumber":118,"sourceCode":"        );\n\n        CommandExecutor commandExecutor = null;\n\n        CommandExecutorFactory shellCommandExecutorFactory = CommandExecutorContext.getShellCommandExecutorFactory();\n\n        if (shellCommandExecutorFactory != null) {\n            // if there is a ShellExecutorFactoryProvided\n            // then it will be used to create a desired shell command executor.\n            commandExecutor = shellCommandExecutorFactory.createExecutor(executorContext);\n        } else {\n            // default Shell executor (if the shell security is OFF)\n            commandExecutor = new ShellCommandExecutor(executorContext);\n        }\n\n        try {\n            commandExecutor.executeCommand(execution);\n        } catch (Exception e) {\n            throw new ActivitiException(\"Could not execute shell command \", e);\n        }\n\n        leave(execution);\n    }\n\n    protected String getStringFromField(Expression expression, DelegateExecution execution) {\n        if (expression != null) {\n            Object value = expression.getValue(execution);\n            if (value != null) {\n                return value.toString();\n            }\n        }\n        return null;\n    }\n}\n","sourceCodeStart":100,"sourceCodeEnd":134,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/ShellActivityBehavior.java#L100-L134","documentation":"A BPMN shell task (ShellActivityBehavior) failed to execute its configured shell command; Activiti wraps the failure in this ActivitiException. The cause carries the underlying error from the command executor.","triggerScenarios":"Shell service task executes and ShellCommandExecutor.executeCommand() throws: command binary not found on PATH, working directory missing, timeout, non-zero/failed execution handling, or invalid shell task field configuration.","commonSituations":"Deploying a process with shell task to an environment lacking the command (e.g. curl/ffmpeg not installed in the container); wrong argument/timeout expressions; running under a user without execute permission; karg variables resolving to null.","solutions":["Check the cause exception for the actual command failure (file not found, exit code, timeout)","Verify the command exists in the runtime environment's PATH (docker exec which <cmd>)","Review the shell task fields: command, arg1..argN, wait, timeout, outputVariable expressions","Prefer a dedicated worker/REST call over shell tasks in containers; or install the required binary in the image"],"exampleFix":"<!-- before -->\n<serviceTask id=\"sh\" activiti:delegateExpression=\"${shellActivityBehavior}\">\n  <extensionElements><activiti:field name=\"command\" expression=\"ffmpeg\"/></extensionElements>\n<!-- after (image includes binary or use absolute path) -->\n<extensionElements><activiti:field name=\"command\" expression=\"/usr/local/bin/ffmpeg\"/></extensionElements>","handlingStrategy":"validation","validationCode":"// before deploying a process with a shell task\nString cmd = \"ffmpeg\";\nif (Stream.of(System.getenv(\"PATH\").split(File.pathSeparator))\n    .noneMatch(p -> new File(p, cmd).canExecute())) {\n  throw new IllegalStateException(\"Shell task command not available: \" + cmd);\n}","typeGuard":null,"tryCatchPattern":"try {\n  runtimeService.startProcessInstanceByKey(\"shellProc\", vars);\n} catch (ActivitiException e) {\n  if (e.getMessage().startsWith(\"Could not execute shell command\")) {\n    log.error(\"Shell task failed: {}\", e.getCause(), e);\n  }\n  throw e;\n}","preventionTips":["Use absolute paths for shell task commands","Verify required binaries exist in the deployment image/container","Prefer service delegates/REST calls over shell tasks in containerized environments","Set wait/timeout fields explicitly so hung commands fail predictably"],"tags":["shell-task","command-execution","bpmn","environment"],"backgroundTag":"command-not-found","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}