org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered

Spring JIRA | member sound | 2 years ago
  1. 0

    I'm starting batch jobs with @Scheduled with fixedDelay. Since latest version the jobs fails as it has not been registered yet to the job repository. This is solved if I put a initialDelay to the annotation. So I assume there are some loader timing issues. Which may be critical for people also relying on @Scheduled with fixedDelay! {code} @Configuration public class BatchConfig { @Bean public ApplicationContextFactory myJob() { return new GenericApplicationContextFactory(MyJob.class); } } @Service public class RunnerClass { @Autowired private JobRegistry jobRegistry; @Autowired private JobLauncher jobLauncher; @Scheduled(fixedDelay = 30000) //fix: , initialDelay = 5000) public void runJob() throws Exception { //init Job job = jobRegistry.getJob(MyJob.class.getSimpleName()); jobLauncher.run(job, params); } } {code} Running without the initialDelay throws the following exception: {code} org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE] at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_51] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [?:1.7.0_51] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_51] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_51] at java.lang.Thread.run(Thread.java:744) [?:1.7.0_51] {code} spring-boot-1.2.0.RELEASE

    Spring JIRA | 2 years ago | member sound
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered
  2. 0

    I'm starting batch jobs with @Scheduled with fixedDelay. Since latest version the jobs fails as it has not been registered yet to the job repository. This is solved if I put a initialDelay to the annotation. So I assume there are some loader timing issues. Which may be critical for people also relying on @Scheduled with fixedDelay! {code} @Configuration public class BatchConfig { @Bean public ApplicationContextFactory myJob() { return new GenericApplicationContextFactory(MyJob.class); } } @Service public class RunnerClass { @Autowired private JobRegistry jobRegistry; @Autowired private JobLauncher jobLauncher; @Scheduled(fixedDelay = 30000) //fix: , initialDelay = 5000) public void runJob() throws Exception { //init Job job = jobRegistry.getJob(MyJob.class.getSimpleName()); jobLauncher.run(job, params); } } {code} Running without the initialDelay throws the following exception: {code} org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE] at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81) [spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_51] at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178) [?:1.7.0_51] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292) [?:1.7.0_51] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_51] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_51] at java.lang.Thread.run(Thread.java:744) [?:1.7.0_51] {code} spring-boot-1.2.0.RELEASE

    Spring JIRA | 2 years ago | member sound
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [myJob] was registered
  3. 0

    @Scheduled with fixedDelay fails on startup

    GitHub | 2 years ago | sddakoty
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [MyJobConfig] was registered
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spring Batch restart persistent jobs after abnormal termination

    Stack Overflow | 1 year ago | alexanoid
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [job] was registered
  6. 0

    Set job status to FAILED when killed

    Stack Overflow | 1 year ago | jmmut
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [importUserJob] was registered

    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. org.springframework.batch.core.launch.NoSuchJobException

      No job configuration with the name [myJob] was registered

      at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob()
    2. Spring Batch Core
      MapJobRegistry.getJob
      1. org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66)[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
      1 frame
    3. Spring Context
      ReschedulingRunnable.run
      1. org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
      2. org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)[spring-context-4.1.3.RELEASE.jar:4.1.3.RELEASE]
      2 frames
    4. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[?:1.7.0_51]
      2. java.util.concurrent.FutureTask.run(FutureTask.java:262)[?:1.7.0_51]
      3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[?:1.7.0_51]
      4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[?:1.7.0_51]
      5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[?:1.7.0_51]
      6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[?:1.7.0_51]
      7. java.lang.Thread.run(Thread.java:744)[?:1.7.0_51]
      7 frames