Spring Scheduler stops unexpectedly

Related searches

We have a Spring 3 web application on Tomcat 6 that uses several scheduled services via @Scheduled (mainly for jobs that run every night). Now it appears that sometimes (rarely, perhaps once in two months or so) the scheduler thread stops working, so none of the jobs will be executed in the following night. There is no exception or logging entry in our log files.

Has anybody a clue why this is happening? Or how to get more information about this problem?

Is there a way to detect this situation within the application and to restart the scheduler?

Currently we are solving this by having also a logging job that runs every 5 minutes and creates a log entry. If the log file stops being updated (monitored by nagios), we know it is time to restart tomcat. It would be nice to restart the jobs without a complete server restart.

Since this question got so many votes, I'll post what the (probably very specific) solution to my problem was.

We are using the Apache HttpClient library to make calls to remote services in the scheduled jobs. Unfortunately there are no default timeouts set when performing requests. After setting


to 30 seconds the problem was gone.

int timeout = 30 * 1000; // 30 seconds
RequestConfig requestConfig = RequestConfig.custom()
HttpClient client = HttpClients.custom()

Spring 4 @Scheduled stops working, 2 Answers. Such a situation might be caused by an infinite loop in the body of the scheduled method or if there is a call to an external system and the control waits synchronously to receive the response without any timeout. Try it by yourself with this simple code snippet. Does the scheduler stop/fail due to external reasons like thread pool max size reached etc. I ask this because my scheduler is expected to run indefinitely but it stops unexpectedly. Regards, Lakshmi Venkateswaran.

This is pretty easy to find out. You would be doing this with a stack trace. There are many posts on how to get a stack trace, on unix system you do 'kill -3 ' and the stack trace appears in the catalina.out log file.

Once you have a stack trace, find the scheduler thread and see what it is doing. Is it possible that the task it was executing got stuck?

you can also post the stack trace here for more help.

what is important to know is what scheduler you use. if you use the SimpleAsyncTaskExecutor, it will start a new thread for each task, and your scheduling will never fail. However, if you have tasks that don't finish, you will run out of memory eventually.


Methods annotated with @Scheduled stops working in Open Source , You have a Spring/Spring Boot app where you have a methods annotate with @ Scheduled and you configured it to run using a cron� Spring Scheduler stops unexpectedly. 8. Scheduling a task in PHP MVC Codeigniter. 809. How to configure port for a Spring Boot application. 3. Scheduling a Task for

In my case stack trace was absolutely clean, thread started only a couple of time and that's all. The problem was in conflict with another schedule.


Schedule not work correctly, because I use fixedDelayString and the previous job not ended when was time to start new. After changed schedule to fixedRateString, threads started correctly.

Spring @Scheduled stops running when system time set back , I have Spring Boot based cron job running: @Scheduled(cron = "30 * * * * *}") public void cronCheck() { logger.debug("now is {}"� I have a Spring-Boot application with a bean running a scheduled task at about 1 minute intervals, Spring Scheduler stops unexpectedly. 194.

Scheduled jobs may stall and fail to process if one job becomes stuck, Scheduled jobs that normally run frequently (such as the Flush Index Queue task) will fail to run. Thread for more information regarding indexing jobs that was stopped caused by intermittent connection issue to the database. Configuring scheduler via XML “threadpooltaskscheduler” In our last example, we use task namespace based XML tags to configure a scheduler. <task:annotation-driven/> will configure the task scheduler bean processor. We can create a task scheduler bean and specify the task scheduler bean name in attribute scheduler. applicationContext.xml:

Why Spring scheduler stopped unexpectedly - spring - html, We have the below scheduler defined in spring context xml file. <!-- Item Scheduling --> <task:scheduler id="itemScheduler" pool-size="1"/>� In my webapp i have classes that used to extend thread class with a run() routine. I had problems with them when shutting down tomcat so replaced the thread implementations with a ScheduledExecutorService. However it still does not work: When shutting down tomcat in my eclipse console there are logg

If the app shuts down unexpectedly (for example, the app's process fails), StopAsync might not be called. Therefore, any methods called or operations conducted in StopAsync might not occur. To extend the default five second shutdown timeout, set: ShutdownTimeout when using Generic Host. For more information, see .NET Generic Host.

  • What is the work being done in the scheduled tasks? Is it possible that something becomes stuck in an infinite loop? I ask because the scheduled tasks, by default, use a threadpool of 1 thread, and if it gets hung somehow, your future tasks will not be started (but I am sure they would be queued).
  • @nicholas.hauschild It calls an external REST webservice. So you are saying that such a request might possibly block (deadlock?) and therefore stop all other jobs. I think I will request a thread dump of the server if this happens again. Thanks for your input.
  • Taking a thread dump will probably be a good idea.
  • Things to consider 1 - Enforce a timeout on the call to the REST service. Maybe even spawn that call in a separate thread and kill it if there is no response within a specified time.
  • Things to consider 2 - Control scheduling from outside your web application. It tends to be more reliable/controllable that way. Maybe take a look at Spring Batch as a means of controlling and monitoring jobs.
  • I was facing the EXACT same problem down to using Apache HttpClient.... You, my friend, are a gentleman and a scholar!
  • This was indeed my problem as well, specifically was using Jersey with the ApacheConnector configured with a PoolingHttpClientConnectionManager. It's critical to set the connectionRequestTimeout parameter as the pool could hang indefinitely if this is not set. To do this, you have to set it in a RequestConfig and set the entire request config in the connector client config like so: RequestConfig rc = RequestConfig.custom().setConnectTimeout(2000).setSocketTimeout(2000).setConnectionRequestTimeout(200).build(); clientConfig.property(ApacheClientProperties.REQUEST_CONFIG, rc);
  • Thanks - taking a thread dump has already been proposed by nicolas.hausschild and I have found a blocked HTTP call from the REST service. I have updated the HttpClient library and I wonder if this might solve the problem already.