java.lang.IllegalStateException: Failed to execute CommandLineRunner

Spring JIRA | Kiichi Kuramoto | 2 months ago
  1. 0

    In Spring Batch 3.0.7 when I define multiple datasources in JavaConfig and run application, an exception occures below: {panel:title=stackTrace} java.lang.IllegalStateException: Failed to execute CommandLineRunner at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] at com.example.BatchMultidatasourceApplication.main(BatchMultidatasourceApplication.java:59) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_77] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_77] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_77] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_77] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:na] Caused by: java.lang.IllegalStateException: To use the default BatchConfigurer the context must contain no more thanone DataSource, found 2 at org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.getConfigurer(AbstractBatchConfiguration.java:108) ~[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE] at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.initialize(SimpleBatchConfiguration.java:114) ~[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE] at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$ReferenceTargetSource.createObject(SimpleBatchConfiguration.java:142) ~[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE] at org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:86) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192) ~[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE] at com.sun.proxy.$Proxy44.getJobInstances(Unknown Source) ~[na:na] at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:133) ~[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:214) ~[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:233) ~[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:125) ~[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:119) ~[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE] at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800) [spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE] ... 11 common frames omitted {panel} This is because AbstractBatchConfiguration to claims "one" dataSource with creating DefaultBatchConfigurer as conditions, although autowiring Collection<DataSource> type. In Spring Boot Reference Guide, mentions that: " You might want to mark one of them as @Primary if you are using the default auto-configuration for JDBC or JPA (then that one will be picked up by any @Autowired injections)." http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-two-datasources I tried this way, but my application did not work because of exceptions above. Therefore, I think that the dataSources field in AbstractBatchConfiguration shoud be defined not as Collection<DataSource> but as DataSource.

    Spring JIRA | 2 months ago | Kiichi Kuramoto
    java.lang.IllegalStateException: Failed to execute CommandLineRunner
  2. 0

    Not able to configure localSegment as Distruptor command bus with Distributed command bus

    Google Groups | 1 year ago | Sankalp Sontakke
    java.lang.IllegalStateException: If no specific CommandBus is provided, the application context must contain exactly one bean of type CommandBus. The current application context has: 2
  3. 0

    No CacheResolver specified--Integration redis with spring boot

    Stack Overflow | 7 months ago | Terry
    java.lang.IllegalStateException: No CacheResolver specified, and no unique bean of type CacheManager found. Mark one as primary (or give it the name 'cacheManager') or declare a specific CacheManager to use, that serves as the default one.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    RE: Multipart Forms - more than one @FormDataParam

    incubator-wink-user | 4 years ago | Kallen McInerney
    java.lang.IllegalStateException: The TestService.test method has more than one entity parameter. You must use only one entity parameter.
  6. 0

    [MULE-3142] Multiple Connectors complain about specifying explicit connector on endpoint - JIRA

    mulesoft.org | 2 months ago
    java.lang.IllegalStateException: There are at least 2 connectors matching protocol "http", so the connector to use must be specified on the endpoint using the 'connector' property/attribute

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalStateException

      To use the default BatchConfigurer the context must contain no more thanone DataSource, found 2

      at org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.getConfigurer()
    2. Spring Batch Core
      SimpleBatchConfiguration$ReferenceTargetSource.createObject
      1. org.springframework.batch.core.configuration.annotation.AbstractBatchConfiguration.getConfigurer(AbstractBatchConfiguration.java:108)[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE]
      2. org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.initialize(SimpleBatchConfiguration.java:114)[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE]
      3. org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$ReferenceTargetSource.createObject(SimpleBatchConfiguration.java:142)[spring-batch-core-3.0.7.RELEASE.jar:3.0.7.RELEASE]
      3 frames
    3. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.target.AbstractLazyCreationTargetSource.getTarget(AbstractLazyCreationTargetSource.java:86)[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      2. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)[spring-aop-4.3.3.RELEASE.jar:4.3.3.RELEASE]
      2 frames
    4. com.sun.proxy
      $Proxy44.getJobInstances
      1. com.sun.proxy.$Proxy44.getJobInstances(Unknown Source)[na:na]
      1 frame
    5. Spring Boot AutoConfigure
      JobLauncherCommandLineRunner.run
      1. org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.getNextJobParameters(JobLauncherCommandLineRunner.java:133)[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      2. org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.execute(JobLauncherCommandLineRunner.java:214)[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      3. org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.executeLocalJobs(JobLauncherCommandLineRunner.java:233)[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      4. org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.launchJobFromProperties(JobLauncherCommandLineRunner.java:125)[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      5. org.springframework.boot.autoconfigure.batch.JobLauncherCommandLineRunner.run(JobLauncherCommandLineRunner.java:119)[spring-boot-autoconfigure-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      5 frames
    6. Spring Boot
      SpringApplication.run
      1. org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      2. org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      3. org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:771)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      4. org.springframework.boot.SpringApplication.run(SpringApplication.java:316)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      5. org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      6. org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)[spring-boot-1.4.1.RELEASE.jar:1.4.1.RELEASE]
      6 frames
    7. com.example
      BatchMultidatasourceApplication.main
      1. com.example.BatchMultidatasourceApplication.main(BatchMultidatasourceApplication.java:59)[classes/:na]
      1 frame
    8. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.8.0_77]
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[na:1.8.0_77]
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.8.0_77]
      4. java.lang.reflect.Method.invoke(Method.java:498)[na:1.8.0_77]
      4 frames
    9. IDEA
      AppMain.main
      1. com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)[idea_rt.jar:na]
      1 frame