apache/dolphinscheduler · error · TaskExecutionContextCreateException
TaskExecutionContextCreateException(ex.getMessage())
Error message
TaskExecutionContextCreateException(ex.getMessage())
What it means
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.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/task/statemachine/TaskSubmittedStateAction.java:122
taskInstance.getFirstSubmitTime(),
taskInstance.getDelayTime() * 60L) * 1_000;
if (remainTimeMills > 0) {
taskInstance.setState(TaskExecutionStatus.DELAY_EXECUTION);
taskInstanceDao.updateById(taskInstance);
log.info("Current taskInstance: {} is choose delay execution, delay time: {}/min, remainTime: {}/ms",
taskInstance.getName(),
taskInstance.getDelayTime(),
remainTimeMills);
}
try {
taskExecution.initializeTaskExecutionContext();
} catch (Exception ex) {
if (ExceptionUtils.isDatabaseConnectedFailedException(ex)) {
throw ex;
}
log.error("Failed to initialize task execution context, taskName: {}", taskInstance.getName(), ex);
throw new TaskExecutionContextCreateException(ex.getMessage());
}
workerGroupDispatcherCoordinator.dispatchTask(taskExecution, remainTimeMills);
}
@Override
public void onDispatchedEvent(final IWorkflowExecution workflowExecution,
final ITaskExecution taskExecution,
final TaskDispatchedLifecycleEvent taskDispatchedEvent) {
throwExceptionIfStateIsNotMatch(taskExecution);
super.onDispatchedEvent(workflowExecution, taskExecution, taskDispatchedEvent);
}
@Override
public void onPauseEvent(final IWorkflowExecution workflowExecution,
final ITaskExecution taskExecution,
final TaskPauseLifecycleEvent taskPauseEvent) {
throwExceptionIfStateIsNotMatch(taskExecution);View on GitHub (pinned to 02eac45a1b)
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
Example fix
// before
throw new TaskExecutionContextCreateException(ex.getMessage()); // loses stack
// after
throw new TaskExecutionContextCreateException("init failed for task " + taskInstance.getName(), ex); Defensive patterns
Strategy: try-catch
Validate before calling
// validate task params before submit
if (taskInstance.getTaskParams() == null || taskInstance.getTaskParams().isEmpty()) throw new IllegalArgumentException("empty taskParams"); Try / catch
try { dispatch(taskExecution); } catch (TaskExecutionContextCreateException e) { log.error("context init failed: {}", e.getMessage(), e); markTaskFailed(taskInstance); } Prevention
- Validate task definitions and parameters before submitting the workflow
- Keep task plugins and their dependencies installed on the master
- Align master/worker versions
When it happens
Trigger: taskExecution.initializeTaskExecutionContext() fails due to bad task parameters, missing resource/plugin config, or any non-DB exception during onDispatchEvent of TaskSubmittedStateAction.
Common situations: Misconfigured task plugins, corrupt task instance parameters in DB, missing JARs/resources needed to build the execution context.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- "Dispatch LogicTask to %s failed, response is: %s" (formatte
- "Dispatch task: " + taskExecution.getName() + " to executor
- CommandDuplicateHandleException(command)
- "The post SerialCommand except WAITING state but -> " + seri
- "WorkflowSerialCoordinator is already started"
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/a4de65c4f90d2424.
Report an issue: GitHub.