[Logo] Terracotta Discussion Forums (LEGACY READ-ONLY ARCHIVE)
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Quartz scheduler threads not getting destroyed (Tomcat7 shutdown & memory leak)  XML
Forum Index -> Quartz
Author Message
am_84

neo

Joined: 09/03/2013 22:55:19
Messages: 1
Offline

Hello,

I am using 2.2.0 version of quartz scheduler along with SPRING 3.2.0_RELEASE, tomcat7 and jdk7.

I can see my cron running correctly but when i shutdown tomcat, the threads are not getting destroyed causing tomcat to never shutdown and throwing the following memory leak error.

SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/temp] appears to have started a thread named [QuartzScheduler_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
Sep 03, 2013 10:43:09 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

I followed the steps documented at following but it didn't help. Please advise on how to proceed ?
http://quartz-scheduler.org/documentation/quartz-2.2.x/cookbook/ServletInitScheduler

My bean config is as following:

@Bean
public JobDetailFactoryBean tempJob() {
final JobDetailFactoryBean tempFactory = new JobDetailFactoryBean();
tempFactory.setJobClass(ActivityNotificationMetricsJob.class);
tempFactory.setName("TEMP_JOB_NAME");
tempFactory.setDurability(true);
final Map<String, Job> jobData = new HashMap<String, Job>();
jobData.put("tempTask", tempTask());
tempFactory.setJobDataAsMap(jobData);
tempFactory.afterPropertiesSet();
return tempFactory;
}

@Bean
public SimpleTriggerFactoryBean tempSimpleTrigger() throws ParseException {
final SimpleTriggerFactoryBean tempSimpleTriggerFactory = new SimpleTriggerFactoryBean();
tempSimpleTriggerFactory.setName("TEMP_TRIGGER_NAME");
tempSimpleTriggerFactory.setJobDetail(tempJob().getObject());
tempSimpleTriggerFactory.setStartDelay(5 * 1000);
tempSimpleTriggerFactory.setRepeatInterval(5 * 1000);
tempSimpleTriggerFactory.afterPropertiesSet();
return tempSimpleTriggerFactory;
}

@Bean
public SchedulerFactoryBean tempSchedulerFactory() throws Exception {
final SchedulerFactoryBean tempSchedulerFactory = new SchedulerFactoryBean();
tempSchedulerFactory.setJobDetails(new JobDetail[] { tempJob()
.getObject() });
tempSchedulerFactory.setTriggers(new Trigger[] { tempSimpleTrigger()
.getObject() });
tempSchedulerFactory.afterPropertiesSet();
return tempSchedulerFactory;
}


Thanks,
Amar
light5

ophanim
[Avatar]
Joined: 01/14/2011 20:32:56
Messages: 554
Offline

Can you try this setting?

Code:
      <context-param>
          <param-name>quartz:wait-on-shutdown</param-name>
          <param-value>true</param-value>
      </context-param>
 


Also, ensure none of your jobs are blocking the schedulers when it needs to shutdown.

What I observe is that even with this, the Tomcat server is picking about Thread used in context that is not shutdown fast enough. Sometimes we need to delay the webapp during servletcontext#detroy slightly just to avoid that WARNING. The WARNING is harmless if you can test scheduler is working and able to shutdown fully in command line mode.

Zemian Deng
---------------
Looking for a web UI to manage Quartz?
Try http://code.google.com/p/myschedule
[WWW]
agthomas

neo

Joined: 11/02/2015 13:32:19
Messages: 1
Offline

I am having the same issue. None of the solution is working. Appreciate if someone can share how this issue has been resolved.
Using Tomcat 8.0.24, Quartz 2.2.2 , Spring 4.1.8 and JDK 8
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team