I wanted to Persist Spring Batch Meta Data related to Jobs/Steps instead of Using MapJobRepository, as it is not recommended for Production Use.
I have extended DefaultBatchConfigurer and have overridden the methods to use My Primary DataSource and Transaction Manager by using JobRepositoryFactoryBean.
Also i have Registered SimpleJobLauncher bean to use custom job repository , for which i have used the below code
@Bean
SimpleJobLauncher simpleJobLauncher() throws Exception {
SimpleJobLauncher simpleJobLauncher= new SimpleJobLauncher();
simpleJobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
simpleJobLauncher.setJobRepository(customRepository());
return simpleJobLauncher;
}
@Bean
public JobRepository customRepository() throws Exception {
JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
jobRepositoryFactoryBean.setDataSource(myPrimaryDataSource);
jobRepositoryFactoryBean.setTransactionManager(myTransactionManager);
jobRepositoryFactoryBean.setDatabaseType("MYSQL");
jobRepositoryFactoryBean.setTablePrefix("BATCH_");
jobRepositoryFactoryBean.setMaxVarCharLength(1000);
return jobRepositoryFactoryBean.getObject();
}
I am facing with below exception when i launch the job
java.lang.NullpointerException:null
at org.springframework.batch.core.repository.dao.MapJobExecutionDao:synchronizeStatus(MapJobExecutionDao.java 161)
Please do let me know where exactly my configuration is wrong.