Skip to content

@Scheduled with fixedDelay fails on startup #2310

@membersound

Description

@membersound

Example project: https://drive.google.com/file/d/0B0qVi9D7R5MZeUYyeVlybkhhR3M/view?usp=sharing

Main Problem:
When scheduling a job with @Scheduled(fixedDelay), it will be executed immediatelly. Since spring-boot.1.2.0.RELEASE this does not work anymore and fails with the following exception.

The issue can be temporary fixed by appending @Scheduled(fixedDelay, initialDelay), but that should just be a workaround.

The example project demostrates that a simple functionless job is only found when using the initialDelay.

2015-01-08 15:06:40.284  INFO 12440 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2015-01-08 15:06:40.284 ERROR 12440 --- [pool-1-thread-1] o.s.s.s.TaskUtils$LoggingErrorHandler    : Unexpected error occurred in scheduled task.

org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [MyJobConfig] was registered
    at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:66)
    at sample.actuator.log4j2.PeriodicJobStarter.runJob(PeriodicJobStarter.java:30)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:744)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions