通过静态调用未能在Spring Cloud数据流中启动任务

时间:2019-01-17 16:31:56

标签: spring-cloud-dataflow

我使用restful调用在spring数据流服务器中成功注册并创建任务。但是当我启动任务时,它失败了。我阅读了所有相关文档,但无法解决。

这是崩溃的代码行:

dataFlowTemplate.taskOperations().launch("task_new10",null,null);

和错误信息:

  

线程“主”中的异常java.lang.NullPointerException       在org.springframework.cloud.dataflow.rest.util.DeploymentPropertiesUtils.format(DeploymentPropertiesUtils.java:244)       在org.springframework.cloud.dataflow.rest.client.TaskTemplate.launch(TaskTemplate.java:141)       在com.ivoyant.registration.RegistrationApplication.main(RegistrationApplication.java:57)

@SpringBootApplication
public class RegistrationApplication {

public RestTemplate restTemplate() {
    RestTemplate restTemplate = new RestTemplate();
    restTemplate.setErrorHandler(new VndErrorResponseErrorHandler(restTemplate.getMessageConverters()));
    for(HttpMessageConverter<?> converter : restTemplate.getMessageConverters()) {
        if (converter instanceof MappingJackson2HttpMessageConverter) {
            final MappingJackson2HttpMessageConverter jacksonConverter =
                    (MappingJackson2HttpMessageConverter) converter;
            jacksonConverter.getObjectMapper()
                    .registerModule(new Jackson2HalModule())
                    .addMixIn(JobExecution.class, JobExecutionJacksonMixIn.class)
                    .addMixIn(JobParameters.class, JobParametersJacksonMixIn.class)
                    .addMixIn(JobParameter.class, JobParameterJacksonMixIn.class)
                    .addMixIn(JobInstance.class, JobInstanceJacksonMixIn.class)
                    .addMixIn(ExitStatus.class, ExitStatusJacksonMixIn.class)
                    .addMixIn(StepExecution.class, StepExecutionJacksonMixIn.class)
                    .addMixIn(ExecutionContext.class, ExecutionContextJacksonMixIn.class)
                    .addMixIn(StepExecutionHistory.class, StepExecutionHistoryJacksonMixIn.class);
        }
    }
    return restTemplate;
}

public static void main(String[] args) throws URISyntaxException {

    RegistrationApplication registrationApplication = new RegistrationApplication();
    DataFlowTemplate dataFlowTemplate = new DataFlowTemplate(
            new URI("http://localhost:9393/"),registrationApplication.restTemplate());

    dataFlowTemplate.appRegistryOperations().register("springBatch", ApplicationType.task,"file:///Users/zheyiyi/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar",null,true);
    dataFlowTemplate.taskOperations().create("task_new10","springBatch");
    dataFlowTemplate.taskOperations().launch("task_new10",null,null);


}

}
  

11:24:52.810 [main]调试org.springframework.web.client.RestTemplate-HTTP GET http://localhost:9393/   11:24:52.867 [main]调试org.springframework.web.client.RestTemplate-Accept = [application / json,application / + json]   11:24:52.880 [main]调试org.springframework.web.client.RestTemplate-响应200 OK   11:24:52.883 [main]调试org.springframework.web.client.RestTemplate-读取[org.springframework.cloud.dataflow.rest.resource.RootResource]   11:24:52.914 [main]调试org.springframework.web.client.RestTemplate-HTTP GET http://localhost:9393/about   11:24:52.929 [main]调试org.springframework.web.client.RestTemplate-Accept = [application / json,application / + json]   11:24:52.931 [main]调试org.springframework.web.client.RestTemplate-响应200 OK   11:24:52.931 [main]调试org.springframework.web.client.RestTemplate-读取[org.springframework.cloud.dataflow.rest.resource.about.AboutResource]   11:24:52.936 [main]调试org.springframework.web.client.RestTemplate-HTTP GET http://localhost:9393/about   11:24:52.936 [main]调试org.springframework.web.client.RestTemplate-Accept = [application / json,application / + json]   11:24:52.940 [main]调试org.springframework.web.client.RestTemplate-响应200 OK   11:24:52.940 [main]调试org.springframework.web.client.RestTemplate-读取[org.springframework.cloud.dataflow.rest.resource.about.AboutResource]   11:24:52.945 [main]调试org.springframework.web.client.RestTemplate-HTTP POST http://localhost:9393/apps/task/springBatch   11:24:52.947 [main]调试org.springframework.web.client.RestTemplate-Accept = [application / json,application / + json]   11:24:52.948 [main]调试org.springframework.web.client.RestTemplate-编写[{uri = [file:///Users/zheyiyi/.m2/repository/com/example/demo/0.0.1-SNAPSHOT /demo-0.0.1-SNAPSHOT.jar],使用org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter强制使用[true]}]   11:24:52.954 [main]调试org.springframework.web.client.RestTemplate-响应201已创建   11:24:52.955 [main]调试org.springframework.web.client.RestTemplate-HTTP POST http://localhost:9393/tasks/definitions   11:24:52.962 [main]调试org.springframework.web.client.RestTemplate-Accept = [application / json,application / * + json]   11:24:52.962 [main]调试org.springframework.web.client.RestTemplate-使用org.springframework.http.converter.support.All.comcomingingFormHttpMessageConverter编写[{name = [task_new10],definition = [springBatch]}]]   11:24:52.971 [main]调试org.springframework.web.client.RestTemplate-响应200 OK   11:24:52.971 [main]调试org.springframework.web.client.RestTemplate-读取[org.springframework.cloud.dataflow.rest.resource.TaskDefinitionResource]   线程“主”中的异常java.lang.NullPointerException       在org.springframework.cloud.dataflow.rest.util.DeploymentPropertiesUtils.format(DeploymentPropertiesUtils.java:244)       在org.springframework.cloud.dataflow.rest.client.TaskTemplate.launch(TaskTemplate.java:141)       在com.ivoyant.registration.RegistrationApplication.main(RegistrationApplication.java:57)

0 个答案:

没有答案