数据流任务不适用于 Spring Batch [英] Dataflow Tasks are not working with Spring Batch

查看:35
本文介绍了数据流任务不适用于 Spring Batch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 Spring Batch job,它也是数据流 task.当我运行此作业时,一切似乎都正常,在 Tasks > Executions 中,我可以看到任务已成功完成.另一方面,当我转到 Jobs 选项卡时,我收到此错误(在命令行中):

I'm having Spring Batch job that is also dataflow task. When I run this job everything seems OK, In Tasks > Executions I can see that tasks finished successfully. On the other hand when I go to Jobs tabs I'm getting this error (in command line):

java.lang.NullPointerException: null
    at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskJobService.getTaskJobExecution(DefaultTaskJobService.java:240) ~[spring-cloud-dataflow-server-core-1.2.2.RELEASE.jar!/:1.2.2.RELEASE]
    at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskJobService.getTaskJobExecutionsForList(DefaultTaskJobService.java:233) ~[spring-cloud-dataflow-server-core-1.2.2.RELEASE.jar!/:1.2.2.RELEASE]
    at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskJobService.listJobExecutions(DefaultTaskJobService.java:103) ~[spring-cloud-dataflow-server-core-1.2.2.RELEASE.jar!/:1.2.2.RELEASE]
    at org.springframework.cloud.dataflow.server.controller.JobExecutionController.list(JobExecutionController.java:91) ~[spring-cloud-dataflow-server-core-1.2.2.RELEASE.jar!/:1.2.2.RELEASE]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_112]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_112]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_112]

Spring Dataflow 版本 = 1.2.2

Spring Dataflow version = 1.2.2

推荐答案

我几天前刚遇到这个问题.出现空指针异常的原因是,当您运行任务时,它的执行被插入到批处理和任务表中,但 TASK_TASK_BATCH 表除外.当您尝试访问 DataFlow 中的作业"选项卡时,它会从该表中读取数据,但找不到该记录,因此会抛出空指针.

I just ran into this issue a couple of days ago. The reason you get a null pointer exception is because when you ran your task, it's execution got inserted into the batch and task tables, except for the TASK_TASK_BATCH table. When you try to access the Jobs tab in DataFlow it reads from this table and cannot find the record so it throws the null pointer.

对我来说,根本原因是因为我从 Spring Boot 应用程序中删除了 spring-boot-starter-parent(因为我需要提供自己的).在这样做的过程中,我删除了 spring-cloud-starter-task 依赖项,以换取 spring-cloud-task-core,认为这就是我在编译时需要看到的所有内容,并且任务运行得很好.我最终发现 spring-cloud-starter-task 不仅包含 spring-cloud-task-core,还包含 spring-cloud-task-batch 和 spring-cloud-任务流.在我的情况下,我缺少 spring-cloud-task-batch 它将记录插入到 TASK_TASK_BATCH 表中.所以我简单地删除了 spring-cloud-task-core,并重新添加了 spring-cloud-starter-task 解决了这个问题.

For me the root cause was because I removed the spring-boot-starter-parent from my spring boot application (since I needed to provide my own). In the process of doing so, I removed the spring-cloud-starter-task dependency, in exchange for the spring-cloud-task-core, thinking this was all I needed seeing as it compiled and the task ran just fine. What I eventually found out was that the spring-cloud-starter-task not only contains the spring-cloud-task-core, but also the spring-cloud-task-batch and the spring-cloud-task-stream. In my case, I was missing spring-cloud-task-batch which is what inserts the records into the TASK_TASK_BATCH table. So I simply removed the spring-cloud-task-core, and re-added spring-cloud-starter-task which solved the issue.

值得一提的是,您还必须通过手动将那些丢失的记录添加到 TASK_TASK_BATCH 表或重置您的批次/任务表/序列来修复数据.希望这会有所帮助!

It's worth mentioning that one will also have to go and fix the data, by either manually adding those missing records to the TASK_TASK_BATCH table, or resetting your batch/task tables/sequences. Hope this helps!

这篇关于数据流任务不适用于 Spring Batch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆