Workflow newChildWorkflowStub creation fails - Called from non workflow or workflow callback thread

This is a Burst Task with parent - child workflows, where Parent workflow calls activity and activity creates child workflows. Creating parent workflow and calling activity part works fine. From Activity when tried to create number of child workflows gets an error as below:

for (task in 1..numTasks) {
    Workflow.newChildWorkflowStub(, childWorkflowOptions)

“thread”:“Activity Executor taskQueue=“PAGE_TASK_QUEUE”, namespace=“default”: 8”,“class”:“io.temporal.internal.sync.POJOActivityTaskHandler”,“exception”:"java.lang.Error: Called from non workflow or workflow callback thread\n\tat io.temporal.internal.sync.DeterministicRunnerImpl.currentThreadInternal(\n\tat io.temporal.internal.sync.WorkflowInternal.getWorkflowInterceptor(\n\tat io.temporal.internal.sync.WorkflowInternal.newChildWorkflowStub(\n\tat io.temporal.workflow.Workflow.newChildWorkflowStub(

Child workflow by definition can be created from a parent workflow code only. Activity code is not considered a part of a workflow. So any code to Workflow.[method] from a non-workflow thread is expected to fail by design.

You either start child workflows from the workflow code or use the WorkflowClient to start non-child workflows from an activity.

1 Like