I'm seeing a problem when I try to get a job execution list either in the UI 'Jobs' tab ('Error fetching data. Is the Data Flow server running?') or via the REST API (500 NullPointerException).
The error from the log is
java.lang.NullPointerException: null
at org.springframework.cloud.dataflow.server.service.impl.DefaultTaskJobService.getTaskJobExecution(DefaultTaskJobService.java:231) ~[spring-cloud-dataflow-server-core-1.1.2.RELEASE.jar!/:1.1.2.RELEASE]
which seems to be caused by the code:
taskExplorer.getTaskExecutionIdByJobExecutionId(jobExecution.getId())
Looking into this it seems some of my jobs have not been associated with task ids - ie there is no entry in the task_task_batch table and if I try to retrieve one of those jobs or a list of all jobs I get the NullPointerException.
Retrieving a job directly by id which does have an association in the task_task_batch table is OK.
Investigating why this is happening with some of my job tasks it seems to be because some of them use XML instead of Java Config to configure the jobs (We have some pre-existing complex jobs that we are moving from XD to Spring Cloud Data Flow and keeping the XML is the quickest way initially to do this).
Otherwise these jobs are running fine, and logging job/step executions to the DB.
When using XML it seems the taskBatchExecutionListener
is not getting added to the job automatically and so the task/batch association does not get registered.
The code for this is in TaskBatchExecutionListenerBeanPostProcessor
and it could be because when using XML config the job bean is of type JobParserJobFactoryBean
and not AbstractJob
.
If I add the listener manually ie
<listeners>
<listener ref="taskBatchExecutionListener"/>
</listeners>
in the job xml the problem is fixed.
I have a few questions:
1) Is this a bug in Spring Cloud Task - ie its just not handling XML configuration correctly, if so I can raise an issue for this.
2) Should Spring Cloud Dataflow handle this better? It seems a badly behaved task can effectively corrupt the data and stop retrieval of lists containing 'good' jobs too.