I’m trying to implement DeployerPartitonHandler to create pods for each partition using KubernetesTaskLauncher in spring cloud task project which execute the batch job as task in SCDF running in Kubernetes environment.

Batch job first create no of partitions based on the criteria and execute partition steps to read data from table and write into file.

To implement DeployerPartitonHandler with XML Job configuration, I added job configuration class which has bean definition for partition handler and DeployerStepExecutionHandler and added required changes in job XML to map DeployerPartitonHandler to step instead of base TaskExecutorPartitionHandler.

But when executing the job as a Task with these changes, I’m getting

Null pointer Exception for TaskExecution Reference in DeployerPartitonHandler Class.

Getting below error,

java.lang.NullPointerException: null
    at org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorker(DeployerPartitionHandler.java:289) ~[spring-cloud-task-batch-2.1.0.M2.jar:2.1.0.M2]
    at org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorkers(DeployerPartitionHandler.java:265) ~[spring-cloud-task-batch-2.1.0.M2.jar:2.1.0.M2]

Below is the code of DeployerPartitonHandler at line no 289 and its throwing error because TaskExecution object is Null.

arguments.add(formatArgument(SPRING_CLOUD_TASK_NAME, String.format("%s_%s_%s",taskExecution.getTaskName(),

Note: In beforeTask method(defined in DeployerPartitonHandler class ) mentioned below , TaskExecution reference value set properly but when the call come at line 289 then that time TaskExecution comes as Null.

    @BeforeTask
    public void beforeTask(TaskExecution taskExecution) {
        this.taskExecution = taskExecution;

        if(this.commandLineArgsProvider == null) {
            SimpleCommandLineArgsProvider provider = new
                    SimpleCommandLineArgsProvider(taskExecution);
            this.commandLineArgsProvider = provider;

        }
    }

0 Answers