Closed santoshmallah closed 3 months ago
Please provide the following so that we may assist you: Spring Cloud Data Flow Version Spring Cloud Task Version Full stack trace.
Spring Cloud Data Flow Version==> 2.7.1 spring-cloud-task-core/spring-cloud-starter-task ==>2.3.0
2023-02-06 17:40:27.151 INFO 21936 --- [nio-9393-exec-3] o.s.c.d.spi.local.LocalTaskLauncher : Command to be executed: D:\Program Files\RedHat\java-11-openjdk-11.0.14-1\bin\java.exe -jar C:\Users\Santosh Mallah.m2\repository\com\blacklivesbiz\springbatch-csv-postgresql\springbatch-csv-postgresql\0.0.1-SNAPSHOT\springbatch-csv-postgresql-0.0.1-SNAPSHOT.jar --spring.cloud.task.batch.fail-on-job-failure=true --spring.cloud.task.closecontextEnabled=true --Demo-Demo-fileIdentifier=fl_AssetJSON --Demo-Demo-jobName=job --Demo-Demo-jsonData={\"AssetJSON\":["100 of json object in this array"]} --spring.cloud.task.executionid=7895 2023-02-06 17:40:27.199 ERROR 21936 --- [nio-9393-exec-3] o.s.c.d.s.c.RestControllerAdvice : Caught exception while handling a request
java.lang.RuntimeException: Exception trying to launch [AppDeploymentRequest@3c05b80c commandlineArguments = list['--spring.cloud.task.batch.fail-on-job-failure=true
--spring.cloud.task.closecontextEnabled=true
--Demo-Demo-fileIdentifier=fl_AssetJSON
--Demo-Demo-jobName=job
--Demo-Demo-jsonData={"preferredAssetJSON":[]], resource = com.blacklivesbiz.springbatch-csv-postgresql:springbatch-csv-postgresql:jar:0.0.1-SNAPSHOT]
at org.springframework.cloud.deployer.spi.local.LocalTaskLauncher.launch(LocalTaskLauncher.java:126)
at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskExecutionService.executeTask(DefaultTaskExecutionService.java:341)
at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskExecutionService$$FastClassBySpringCGLIB$$422cda43.invoke(
Which version of Windows are you using? What is the default character set when you launch dataflow server?
Windows seem to default to 256 character for filenames and command line.
Create symbolic link that is a short directory name to java.exe and to C:\Users\Santosh Mallah.m2\repository\com\blacklivesbiz\springbatch-csv-postgresql\springbatch-csv-postgresql\0.0.1-SNAPSHOT
Update the registration of the task to use the short name.
You can also try this article to see if increasing the 256 character limitation works.
If possible you can also consider installing WSL (Windows Subsystem for Linux). You will need to install Java for Linux (using SDKMAN makes lite of managing Java versions) and configure WSL to use docker desktop if installed.
NOTE: You are currently working on an unsupported version of Data Flow. Upgrade to SCDF 2.9.x or 2.10.x and Spring Cloud Task 2.4.x
Thank you for your reply, but I just want to remove the java -jar
command which internally spring cloud data flow hits to run the particular task with the argument.
I Try with this way but wont work
package com.exampl.demotask;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.deployer.spi.core.AppDeploymentRequest;
import org.springframework.cloud.deployer.spi.core.RuntimeEnvironmentInfo;
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
import org.springframework.cloud.deployer.spi.task.TaskStatus;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.cloud.task.listener.TaskExecutionListener;
import org.springframework.cloud.task.repository.TaskExecution;
@SpringBootApplication
@EnableTask
public class CustomLocalTaskLauncher implements TaskLauncher{
public static void main(String[] args) {
SpringApplication.run(CustomLocalTaskLauncher.class, args);
}
@Override
public String launch(AppDeploymentRequest request) {
// TODO Auto-generated method stub
System.out.println("===================>"+request.getCommandlineArguments());
System.out.println("Now calling new Api whith following parameter"+request.toString());
return null;
}
@Override
public void cancel(String id) {
System.out.println("inside cancel==>"+id);
// TODO Auto-generated method stub
}
@Override
public TaskStatus status(String id) {
System.out.println("inside status==>"+id);
// TODO Auto-generated method stub
return null;
}
@Override
public void cleanup(String id) {
System.out.println("inside cleanup==>"+id);
// TODO Auto-generated method stub
}
@Override
public void destroy(String appName) {
System.out.println("inside destroy==>"+appName);
// TODO Auto-generated method stub
}
@Override
public RuntimeEnvironmentInfo environmentInfo() {
// TODO Auto-generated method stub
return null;
}
}
package com.exampl.demotask;
import org.springframework.cloud.deployer.spi.task.TaskLauncher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TaskLauncherConfiguration {
@Bean
public TaskLauncher taskLauncher() {
return new CustomLocalTaskLauncher();
}
}
and I have deployed it in the spring cloud data flow, but control does not go into ```public String launch(AppDeploymentRequest request)``` method
From this method I am going to write my custom logic to hit the batch job
So you are creating a task that can launch Spring Boot/Batch apps and launching the task from dataflow?
It is unclear what you are trying to do. Can you provide more detail?
Yes, I am creating a task that can launch Spring Boot/Batch apps and launching the task from dataflow.
Have you looked into composed tasks?
The purpose of scdf is to launch spring cloud tasks/spring batch apps. It seems that the filename or command line options are too long for windows based on the error code in your first post, err 206. Corneil suggested some ways to diagnose that, have your tried that?
If you want your spring batch app or task app to itself launch another process, and I guess you mean a .exe since you said you want to avoid java -jar
. In this case, take a look at the JDK ProcessBuilder to launch an arbitrary executable. You can look https://github.com/spring-cloud/spring-cloud-deployer-local for usage or other tutorials on that JDK class.
Closing due to inactivity. If closed in error please let us know.
When I hit in launch task with an argument internally, it hits
java - jar --<argument>
leads to a problem when I have a large number of data in the parameter .Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
Is there any way to make customization in such a way as to avoid the internal working of SCDF?
Command to be executed: D:\Program Files\RedHat\java-11-openjdk-11.0.14-1\bin\java.exe -jar springbatch-csv-postgresql-0.0.1-SNAPSHOT.jar --spring.cloud.task.batch.fail-on-job-failure=true......................................................................
I want to avoid this