{"record":{"id":"a4de65c4f90d2424","repo":"apache/dolphinscheduler","slug":"taskexecutioncontextcreateexception-ex-getmessage","errorCode":null,"errorMessage":"TaskExecutionContextCreateException(ex.getMessage())","messagePattern":"TaskExecutionContextCreateException\\(ex\\.getMessage\\(\\)\\)","errorType":"exception","errorClass":"TaskExecutionContextCreateException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java","lineNumber":122,"sourceCode":"                taskInstance.getFirstSubmitTime(),\n                taskInstance.getDelayTime() * 60L) * 1_000;\n        if (remainTimeMills > 0) {\n            taskInstance.setState(TaskExecutionStatus.DELAY_EXECUTION);\n            taskInstanceDao.updateById(taskInstance);\n            log.info(\"Current taskInstance: {} is choose delay execution, delay time: {}/min, remainTime: {}/ms\",\n                    taskInstance.getName(),\n                    taskInstance.getDelayTime(),\n                    remainTimeMills);\n        }\n\n        try {\n            taskExecution.initializeTaskExecutionContext();\n        } catch (Exception ex) {\n            if (ExceptionUtils.isDatabaseConnectedFailedException(ex)) {\n                throw ex;\n            }\n            log.error(\"Failed to initialize task execution context, taskName: {}\", taskInstance.getName(), ex);\n            throw new TaskExecutionContextCreateException(ex.getMessage());\n        }\n\n        workerGroupDispatcherCoordinator.dispatchTask(taskExecution, remainTimeMills);\n    }\n\n    @Override\n    public void onDispatchedEvent(final IWorkflowExecution workflowExecution,\n                                  final ITaskExecution taskExecution,\n                                  final TaskDispatchedLifecycleEvent taskDispatchedEvent) {\n        throwExceptionIfStateIsNotMatch(taskExecution);\n        super.onDispatchedEvent(workflowExecution, taskExecution, taskDispatchedEvent);\n    }\n\n    @Override\n    public void onPauseEvent(final IWorkflowExecution workflowExecution,\n                             final ITaskExecution taskExecution,\n                             final TaskPauseLifecycleEvent taskPauseEvent) {\n        throwExceptionIfStateIsNotMatch(taskExecution);","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java#L104-L140","documentation":"Wraps any non-database exception raised while initializing a task's TaskExecutionContext during dispatch. The master aborts dispatching the task to the worker and raises TaskExecutionContextCreateException carrying the original message. DB connectivity failures are rethrown as-is instead.","triggerScenarios":"taskExecution.initializeTaskExecutionContext() fails due to bad task parameters, missing resource/plugin config, or any non-DB exception during onDispatchEvent of TaskSubmittedStateAction.","commonSituations":"Misconfigured task plugins, corrupt task instance parameters in DB, missing JARs/resources needed to build the execution context.","solutions":["Read the wrapped cause message to identify the initialization failure","Fix the task definition parameters or plugin configuration","Verify DB-related failures are surfaced as the original exception (they bypass this wrapper)","Retry the workflow instance after correcting the task config"],"exampleFix":"// before\nthrow new TaskExecutionContextCreateException(ex.getMessage()); // loses stack\n// after\nthrow new TaskExecutionContextCreateException(\"init failed for task \" + taskInstance.getName(), ex);","handlingStrategy":"try-catch","validationCode":"// validate task params before submit\nif (taskInstance.getTaskParams() == null || taskInstance.getTaskParams().isEmpty()) throw new IllegalArgumentException(\"empty taskParams\");","typeGuard":null,"tryCatchPattern":"try { dispatch(taskExecution); } catch (TaskExecutionContextCreateException e) { log.error(\"context init failed: {}\", e.getMessage(), e); markTaskFailed(taskInstance); }","preventionTips":["Validate task definitions and parameters before submitting the workflow","Keep task plugins and their dependencies installed on the master","Align master/worker versions"],"tags":["java","master","task-dispatch"],"backgroundTag":"api-request-failed","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}