Интеграция Spring Batch в существующее приложение Spring. Таблицы созданы. Три новых рабочих места созданы и зарегистрированы. Их можно найти через jobOperator и jobLauncher. Но при вызове NPE выходят из родительского класса Spring предка (AbstractJob).
Я попытался вызвать задание из jobOperator и jobLauncher. Даже сначала поиск работы по имени в jobRepository. Задание начинается, но затем появляются NPE.
@Component("processVlsCasesJob")
@Scope(value = "prototype", proxyMode = ScopedProxyMode.NO)
public class ProcessVlsCasesJobImpl
extends BatchJobAncestorImpl
implements ProcessVlsCasesJob {
...
@SuppressWarnings("serial")
@Component
@Transactional(propagation = Propagation.REQUIRED)
public abstract class BatchJobAncestorImpl
extends SimpleJob
implements BatchJobAncestor {
@Autowired // custom DAO
private BatchAuditDAO batchAuditDAO;
...
public interface BatchJobAncestor extends Job, Serializable {
...
Long jobExecutionId = null;
String parameters = jobParametersExtractor.fromJobParameters(jobParameters);
jobExecutionId = jobOperator.start(result.getJobName(), parameters);
result.setJobExecutionId(jobExecutionId);
Как будто SpringBatch создает новый объект SimpleJob, который не настроен, и пытается запустить его:
2019-01-10 12:54:51.220 INFO org.springframework.batch.core.launch.support.SimpleJobOperator UserId:|IPAddress:|ThreadId:| - Checking status of job with name=ProcessVlsCases
2019-01-10 12:54:51.225 INFO org.springframework.batch.core.launch.support.SimpleJobOperator UserId:|IPAddress:|ThreadId:| - Attempting to launch job with name=ProcessVlsCases and parameters=param_who=AM20909,param_run_type=test,param_submittal_date=2019-01-10 12:54:45
2019-01-10 12:54:51.259 INFO org.springframework.batch.core.launch.support.SimpleJobLauncher UserId:|IPAddress:|ThreadId:| - Job: [ProcessVlsCasesJobImpl: [name=ProcessVlsCases]] launched with the following parameters: [{param_who=AM20909, param_run_type=test, param_submittal_date=2019-01-10 12:54:45}]
2019-01-10 12:54:51.260 ERROR org.springframework.batch.core.job.AbstractJob UserId:|IPAddress:|ThreadId:| - Encountered fatal error executing job
java.lang.NullPointerException: null
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:303) [spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) [spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271) [spring-core-4.3.16.RELEASE.jar:4.3.16.RELEASE]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
2019-01-10 12:54:51.261 ERROR org.springframework.batch.core.job.AbstractJob UserId:|IPAddress:|ThreadId:| - Exception encountered in afterStep callback
java.lang.NullPointerException: null
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:359) [spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) [spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271) [spring-core-4.3.16.RELEASE.jar:4.3.16.RELEASE]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
2019-01-10 12:54:51.261 INFO org.springframework.batch.core.launch.support.SimpleJobLauncher UserId:|IPAddress:|ThreadId:| - Job: [ProcessVlsCasesJobImpl: [name=ProcessVlsCases]] failed unexpectedly and fatally with the following parameters: [{param_who=AM20909, param_run_type=test, param_submittal_date=2019-01-10 12:54:45}]
java.lang.NullPointerException: null
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:364) ~[spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144) [spring-batch-core-4.1.0.RELEASE.jar:4.1.0.RELEASE]
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271) [spring-core-4.3.16.RELEASE.jar:4.3.16.RELEASE]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
2019-01-10 12:54:51.272 DEBUG gov.texas.dps.dl.batch.admin.ui.jobexecutionparameter.BatchJobExecutionParameterDtoEditControllerImpl UserId:|IPAddress:|ThreadId:| - preRenderView
2019-01-10 12:54:51.272 DEBUG gov.texas.dps.dl.batch.admin.ui.jobexecutionparameter.BatchJobExecutionParameterDtoEditControllerImpl UserId:|IPAddress:|ThreadId:| - resetForWork
Exception in thread "dlsBatch_2" java.lang.NullPointerException
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:364)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:144)
at org.springframework.core.task.SimpleAsyncTaskExecutor$ConcurrencyThrottlingRunnable.run(SimpleAsyncTaskExecutor.java:271)
at java.lang.Thread.run(Thread.java:748)
Я не понимаю, почему это происходит. Я могу пройти регистрационную логику в конструктор конкретного класса задания (ProcessVlsCases выше), в его предка, вплоть до SimpleJob (у меня нет источника, поэтому я пропускаю его), а затем вниз в метод @PostConstruct объекта класс бетона.