spring-cloud / spring-cloud-dataflow

A microservices-based Streaming and Batch data processing in Cloud Foundry and Kubernetes
https://dataflow.spring.io
Apache License 2.0
1.11k stars 581 forks source link

Can I run spring cloud task using custom implementation because of this Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long #5211

Closed santoshmallah closed 3 months ago

santoshmallah commented 1 year ago

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

cppwfs commented 1 year ago

Please provide the following so that we may assist you: Spring Cloud Data Flow Version Spring Cloud Task Version Full stack trace.

santoshmallah commented 1 year ago

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() at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:771) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:367) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:749) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:691) at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskExecutionService$$EnhancerBySpringCGLIB$$94c63507.executeTask() at org.springframework.cloud.dataflow.server.controller.TaskExecutionController.launch(TaskExecutionController.java:177) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909) at javax.servlet.http.HttpServlet.service(HttpServlet.java:652) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) at javax.servlet.http.HttpServlet.service(HttpServlet.java:733) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:103) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.io.IOException: Cannot run program "D:\Program Files\RedHat\java-11-openjdk-11.0.14-1\bin\java.exe" (in directory "C:\Users\SANTOS~1\AppData\Local\Temp\234501333708200\Demo-6dc30653-411c-4162-b6db-ea2edca43512"): CreateProcess error=206, The filename or extension is too long at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071) at org.springframework.cloud.deployer.spi.local.LocalTaskLauncher$TaskInstance.start(LocalTaskLauncher.java:350) at org.springframework.cloud.deployer.spi.local.LocalTaskLauncher$TaskInstance.access$200(LocalTaskLauncher.java:254) at org.springframework.cloud.deployer.spi.local.LocalTaskLauncher.launch(LocalTaskLauncher.java:119) ... 70 common frames omitted Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long at java.base/java.lang.ProcessImpl.create(Native Method) at java.base/java.lang.ProcessImpl.(ProcessImpl.java:487) at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107) ... 74 common frames omitted

corneil commented 1 year ago

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.

https://learn.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links

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

santoshmallah commented 1 year ago

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
cppwfs commented 1 year ago

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?

santoshmallah commented 1 year ago

Yes, I am creating a task that can launch Spring Boot/Batch apps and launching the task from dataflow.

corneil commented 1 year ago

Have you looked into composed tasks?

markpollack commented 1 year ago

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.

cppwfs commented 3 months ago

Closing due to inactivity. If closed in error please let us know.