Getting java.lang.IllegalStateException: Failed to execute CommandLineRunner in Spring Batch












0















I am getting the below error when I try to run a spring batch.



java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.amhi.care.claims.query.batch.QueryBatchApplication.main(QueryBatchApplication.java:15) [classes/:na]


Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_192]
at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_192]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:143) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:212) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:231) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:123) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:117) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
... 4 common frames omitted


Code:



@Configuration
@EnableBatchProcessing
@EnableScheduling
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@Import(DataSourcecConfiguration.class)
public class QueryBatchConfiguration {

@Autowired
public JobBuilderFactory jobBuilderFactory;

@Autowired
public StepBuilderFactory stepBuilderFactory;


@Bean
public Job reminderJob() {
return jobBuilderFactory.get("reminderJob").flow(step()).next(closureStep()).end().build();
}

@Bean
public Step step() {
return stepBuilderFactory.get("step").tasklet(tasklet()).build();
}
@Bean
public Step closureStep() {
return stepBuilderFactory.get("closureStep").tasklet(closureTasklet()).build();
}

@Bean
public Tasklet tasklet(){
return new QueryBatchTasklet();
}

@Bean
public Tasklet closureTasklet(){
return new ClosureBatchTasklet();
}


@Bean
@JobScope
public JobParameters jobParamater(){
return new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters();
}

/**
* This method is used to configure the Dozer Mapper
*
* @return Mapper
* @throws IOException
*/
@Bean(name = "mapper")
public Mapper configDozerMapper() throws IOException {

DozerBeanMapper mapper = new DozerBeanMapper();
return mapper;
}

/**
* This method is used to create RIDC client manager
*
* @return IdcClientManager
*/
@Bean(name = "idcClientmanager")
public IdcClientManager idcClientmanager() {
return new IdcClientManager();
}


}



@Configuration
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@PropertySource(QueryBatchConstants.CLASSPATH_APPLICATION_PROPERTIES)
public class DataSourcecConfiguration {

@Resource
private Environment env;

@Autowired
public DataSource dataSource;

/**
* This method is used to configure a data source
*
* @return DataSource
* @throws SQLException
*/
@Bean
public DataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setDriverClassName(env.getRequiredProperty(QueryBatchConstants.DATABASE_DRIVER));
dataSource.setUrl(env.getRequiredProperty(QueryBatchConstants.DATABASE_URL));
dataSource.setUsername(env.getRequiredProperty(QueryBatchConstants.DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(QueryBatchConstants.DATABASE_PSWRD));

return dataSource;
}

/**
* This method is used to configure a entity manager factory
*
* @return LocalContainerEntityManagerFactoryBean
* @throws SQLException
*/
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
entityManager.setDataSource(dataSource());
entityManager.setPersistenceProviderClass(HibernatePersistence.class);
entityManager.setPackagesToScan(env.getRequiredProperty(QueryBatchConstants.PACKAGES_TO_SCAN));
entityManager.setJpaProperties(jpaProperties());

return entityManager;
}

/**
* This method is used to configure the JPA properties
*
* @return JPA Properties
*/
private Properties jpaProperties() {
Properties properties = new Properties();
properties.put(QueryBatchConstants.HIBERNATE_DIALECT, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_DIALECT));
properties.put(QueryBatchConstants.HIBERNATE_SHOW_SQL, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_SHOW_SQL));
properties.put(QueryBatchConstants.HIBERNATE_JDBC_META_DATA, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_FALSE));
return properties;
}

/**
* This method is used to configure the transaction manager
*
* @param emf
* @return JpaTransactionManager
*/
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);

return transactionManager;
}

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setResultsMapCaseInsensitive(true);
return jdbcTemplate;
}


}



@Component
public class QueryBatchTasklet implements Tasklet{

@Autowired
private QueryBatchService autoClosureService;


@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

autoClosureService.updateStatusAndTriggerComm();
return null;
}


}



@Component
public class ClosureBatchTasklet implements Tasklet{

@Autowired
private ClosureBatchService closureBatchService;

@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

closureBatchService.updateStatusAndTriggerComm();
return null;
}


}










share|improve this question























  • Can you add you main method?

    – hasnae
    Nov 28 '18 at 14:25
















0















I am getting the below error when I try to run a spring batch.



java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.amhi.care.claims.query.batch.QueryBatchApplication.main(QueryBatchApplication.java:15) [classes/:na]


Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_192]
at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_192]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:143) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:212) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:231) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:123) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:117) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
... 4 common frames omitted


Code:



@Configuration
@EnableBatchProcessing
@EnableScheduling
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@Import(DataSourcecConfiguration.class)
public class QueryBatchConfiguration {

@Autowired
public JobBuilderFactory jobBuilderFactory;

@Autowired
public StepBuilderFactory stepBuilderFactory;


@Bean
public Job reminderJob() {
return jobBuilderFactory.get("reminderJob").flow(step()).next(closureStep()).end().build();
}

@Bean
public Step step() {
return stepBuilderFactory.get("step").tasklet(tasklet()).build();
}
@Bean
public Step closureStep() {
return stepBuilderFactory.get("closureStep").tasklet(closureTasklet()).build();
}

@Bean
public Tasklet tasklet(){
return new QueryBatchTasklet();
}

@Bean
public Tasklet closureTasklet(){
return new ClosureBatchTasklet();
}


@Bean
@JobScope
public JobParameters jobParamater(){
return new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters();
}

/**
* This method is used to configure the Dozer Mapper
*
* @return Mapper
* @throws IOException
*/
@Bean(name = "mapper")
public Mapper configDozerMapper() throws IOException {

DozerBeanMapper mapper = new DozerBeanMapper();
return mapper;
}

/**
* This method is used to create RIDC client manager
*
* @return IdcClientManager
*/
@Bean(name = "idcClientmanager")
public IdcClientManager idcClientmanager() {
return new IdcClientManager();
}


}



@Configuration
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@PropertySource(QueryBatchConstants.CLASSPATH_APPLICATION_PROPERTIES)
public class DataSourcecConfiguration {

@Resource
private Environment env;

@Autowired
public DataSource dataSource;

/**
* This method is used to configure a data source
*
* @return DataSource
* @throws SQLException
*/
@Bean
public DataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setDriverClassName(env.getRequiredProperty(QueryBatchConstants.DATABASE_DRIVER));
dataSource.setUrl(env.getRequiredProperty(QueryBatchConstants.DATABASE_URL));
dataSource.setUsername(env.getRequiredProperty(QueryBatchConstants.DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(QueryBatchConstants.DATABASE_PSWRD));

return dataSource;
}

/**
* This method is used to configure a entity manager factory
*
* @return LocalContainerEntityManagerFactoryBean
* @throws SQLException
*/
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
entityManager.setDataSource(dataSource());
entityManager.setPersistenceProviderClass(HibernatePersistence.class);
entityManager.setPackagesToScan(env.getRequiredProperty(QueryBatchConstants.PACKAGES_TO_SCAN));
entityManager.setJpaProperties(jpaProperties());

return entityManager;
}

/**
* This method is used to configure the JPA properties
*
* @return JPA Properties
*/
private Properties jpaProperties() {
Properties properties = new Properties();
properties.put(QueryBatchConstants.HIBERNATE_DIALECT, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_DIALECT));
properties.put(QueryBatchConstants.HIBERNATE_SHOW_SQL, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_SHOW_SQL));
properties.put(QueryBatchConstants.HIBERNATE_JDBC_META_DATA, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_FALSE));
return properties;
}

/**
* This method is used to configure the transaction manager
*
* @param emf
* @return JpaTransactionManager
*/
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);

return transactionManager;
}

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setResultsMapCaseInsensitive(true);
return jdbcTemplate;
}


}



@Component
public class QueryBatchTasklet implements Tasklet{

@Autowired
private QueryBatchService autoClosureService;


@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

autoClosureService.updateStatusAndTriggerComm();
return null;
}


}



@Component
public class ClosureBatchTasklet implements Tasklet{

@Autowired
private ClosureBatchService closureBatchService;

@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

closureBatchService.updateStatusAndTriggerComm();
return null;
}


}










share|improve this question























  • Can you add you main method?

    – hasnae
    Nov 28 '18 at 14:25














0












0








0








I am getting the below error when I try to run a spring batch.



java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.amhi.care.claims.query.batch.QueryBatchApplication.main(QueryBatchApplication.java:15) [classes/:na]


Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_192]
at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_192]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:143) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:212) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:231) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:123) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:117) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
... 4 common frames omitted


Code:



@Configuration
@EnableBatchProcessing
@EnableScheduling
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@Import(DataSourcecConfiguration.class)
public class QueryBatchConfiguration {

@Autowired
public JobBuilderFactory jobBuilderFactory;

@Autowired
public StepBuilderFactory stepBuilderFactory;


@Bean
public Job reminderJob() {
return jobBuilderFactory.get("reminderJob").flow(step()).next(closureStep()).end().build();
}

@Bean
public Step step() {
return stepBuilderFactory.get("step").tasklet(tasklet()).build();
}
@Bean
public Step closureStep() {
return stepBuilderFactory.get("closureStep").tasklet(closureTasklet()).build();
}

@Bean
public Tasklet tasklet(){
return new QueryBatchTasklet();
}

@Bean
public Tasklet closureTasklet(){
return new ClosureBatchTasklet();
}


@Bean
@JobScope
public JobParameters jobParamater(){
return new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters();
}

/**
* This method is used to configure the Dozer Mapper
*
* @return Mapper
* @throws IOException
*/
@Bean(name = "mapper")
public Mapper configDozerMapper() throws IOException {

DozerBeanMapper mapper = new DozerBeanMapper();
return mapper;
}

/**
* This method is used to create RIDC client manager
*
* @return IdcClientManager
*/
@Bean(name = "idcClientmanager")
public IdcClientManager idcClientmanager() {
return new IdcClientManager();
}


}



@Configuration
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@PropertySource(QueryBatchConstants.CLASSPATH_APPLICATION_PROPERTIES)
public class DataSourcecConfiguration {

@Resource
private Environment env;

@Autowired
public DataSource dataSource;

/**
* This method is used to configure a data source
*
* @return DataSource
* @throws SQLException
*/
@Bean
public DataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setDriverClassName(env.getRequiredProperty(QueryBatchConstants.DATABASE_DRIVER));
dataSource.setUrl(env.getRequiredProperty(QueryBatchConstants.DATABASE_URL));
dataSource.setUsername(env.getRequiredProperty(QueryBatchConstants.DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(QueryBatchConstants.DATABASE_PSWRD));

return dataSource;
}

/**
* This method is used to configure a entity manager factory
*
* @return LocalContainerEntityManagerFactoryBean
* @throws SQLException
*/
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
entityManager.setDataSource(dataSource());
entityManager.setPersistenceProviderClass(HibernatePersistence.class);
entityManager.setPackagesToScan(env.getRequiredProperty(QueryBatchConstants.PACKAGES_TO_SCAN));
entityManager.setJpaProperties(jpaProperties());

return entityManager;
}

/**
* This method is used to configure the JPA properties
*
* @return JPA Properties
*/
private Properties jpaProperties() {
Properties properties = new Properties();
properties.put(QueryBatchConstants.HIBERNATE_DIALECT, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_DIALECT));
properties.put(QueryBatchConstants.HIBERNATE_SHOW_SQL, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_SHOW_SQL));
properties.put(QueryBatchConstants.HIBERNATE_JDBC_META_DATA, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_FALSE));
return properties;
}

/**
* This method is used to configure the transaction manager
*
* @param emf
* @return JpaTransactionManager
*/
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);

return transactionManager;
}

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setResultsMapCaseInsensitive(true);
return jdbcTemplate;
}


}



@Component
public class QueryBatchTasklet implements Tasklet{

@Autowired
private QueryBatchService autoClosureService;


@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

autoClosureService.updateStatusAndTriggerComm();
return null;
}


}



@Component
public class ClosureBatchTasklet implements Tasklet{

@Autowired
private ClosureBatchService closureBatchService;

@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

closureBatchService.updateStatusAndTriggerComm();
return null;
}


}










share|improve this question














I am getting the below error when I try to run a spring batch.



java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at com.amhi.care.claims.query.batch.QueryBatchApplication.main(QueryBatchApplication.java:15) [classes/:na]


Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[na:1.8.0_192]
at java.util.ArrayList.get(ArrayList.java:433) ~[na:1.8.0_192]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:143) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:212) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:231) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:123) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:117) ~[spring-boot-autoconfigure-1.5.3.RELEASE.jar:1.5.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
... 4 common frames omitted


Code:



@Configuration
@EnableBatchProcessing
@EnableScheduling
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@Import(DataSourcecConfiguration.class)
public class QueryBatchConfiguration {

@Autowired
public JobBuilderFactory jobBuilderFactory;

@Autowired
public StepBuilderFactory stepBuilderFactory;


@Bean
public Job reminderJob() {
return jobBuilderFactory.get("reminderJob").flow(step()).next(closureStep()).end().build();
}

@Bean
public Step step() {
return stepBuilderFactory.get("step").tasklet(tasklet()).build();
}
@Bean
public Step closureStep() {
return stepBuilderFactory.get("closureStep").tasklet(closureTasklet()).build();
}

@Bean
public Tasklet tasklet(){
return new QueryBatchTasklet();
}

@Bean
public Tasklet closureTasklet(){
return new ClosureBatchTasklet();
}


@Bean
@JobScope
public JobParameters jobParamater(){
return new JobParametersBuilder()
.addDate("date", new Date())
.toJobParameters();
}

/**
* This method is used to configure the Dozer Mapper
*
* @return Mapper
* @throws IOException
*/
@Bean(name = "mapper")
public Mapper configDozerMapper() throws IOException {

DozerBeanMapper mapper = new DozerBeanMapper();
return mapper;
}

/**
* This method is used to create RIDC client manager
*
* @return IdcClientManager
*/
@Bean(name = "idcClientmanager")
public IdcClientManager idcClientmanager() {
return new IdcClientManager();
}


}



@Configuration
@EnableTransactionManagement
@ComponentScan(QueryBatchConstants.COMPONENT_SCAN_PACKAGE)
@PropertySource(QueryBatchConstants.CLASSPATH_APPLICATION_PROPERTIES)
public class DataSourcecConfiguration {

@Resource
private Environment env;

@Autowired
public DataSource dataSource;

/**
* This method is used to configure a data source
*
* @return DataSource
* @throws SQLException
*/
@Bean
public DataSource dataSource() throws SQLException {
DriverManagerDataSource dataSource = new DriverManagerDataSource();

dataSource.setDriverClassName(env.getRequiredProperty(QueryBatchConstants.DATABASE_DRIVER));
dataSource.setUrl(env.getRequiredProperty(QueryBatchConstants.DATABASE_URL));
dataSource.setUsername(env.getRequiredProperty(QueryBatchConstants.DATABASE_USERNAME));
dataSource.setPassword(env.getRequiredProperty(QueryBatchConstants.DATABASE_PSWRD));

return dataSource;
}

/**
* This method is used to configure a entity manager factory
*
* @return LocalContainerEntityManagerFactoryBean
* @throws SQLException
*/
@Autowired
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() throws SQLException {
LocalContainerEntityManagerFactoryBean entityManager = new LocalContainerEntityManagerFactoryBean();
entityManager.setDataSource(dataSource());
entityManager.setPersistenceProviderClass(HibernatePersistence.class);
entityManager.setPackagesToScan(env.getRequiredProperty(QueryBatchConstants.PACKAGES_TO_SCAN));
entityManager.setJpaProperties(jpaProperties());

return entityManager;
}

/**
* This method is used to configure the JPA properties
*
* @return JPA Properties
*/
private Properties jpaProperties() {
Properties properties = new Properties();
properties.put(QueryBatchConstants.HIBERNATE_DIALECT, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_DIALECT));
properties.put(QueryBatchConstants.HIBERNATE_SHOW_SQL, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_SHOW_SQL));
properties.put(QueryBatchConstants.HIBERNATE_JDBC_META_DATA, env.getRequiredProperty(QueryBatchConstants.HIBERNATE_FALSE));
return properties;
}

/**
* This method is used to configure the transaction manager
*
* @param emf
* @return JpaTransactionManager
*/
@Bean
public JpaTransactionManager transactionManager(EntityManagerFactory emf) {
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);

return transactionManager;
}

@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.setResultsMapCaseInsensitive(true);
return jdbcTemplate;
}


}



@Component
public class QueryBatchTasklet implements Tasklet{

@Autowired
private QueryBatchService autoClosureService;


@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

autoClosureService.updateStatusAndTriggerComm();
return null;
}


}



@Component
public class ClosureBatchTasklet implements Tasklet{

@Autowired
private ClosureBatchService closureBatchService;

@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {

closureBatchService.updateStatusAndTriggerComm();
return null;
}


}







java spring-boot






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 14:21









bharathibharathi

2,2261764116




2,2261764116













  • Can you add you main method?

    – hasnae
    Nov 28 '18 at 14:25



















  • Can you add you main method?

    – hasnae
    Nov 28 '18 at 14:25

















Can you add you main method?

– hasnae
Nov 28 '18 at 14:25





Can you add you main method?

– hasnae
Nov 28 '18 at 14:25












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53521599%2fgetting-java-lang-illegalstateexception-failed-to-execute-commandlinerunner-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53521599%2fgetting-java-lang-illegalstateexception-failed-to-execute-commandlinerunner-in%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)