Estou utilizando o Quartz para rodar minhas Jobs e estas estão funcionando perfeitamente.
O problema está no termino da execução delas.
No servidor ao terminar de rodar as Jobs o tomcat também para de rodar e para a aplicação funcionar novamente tenho que reiniciar o tomcat.
No Context.xml está desta forma.
<bean name="quartzServiceAlerta" class="org.springframework.scheduling.quartz.JobDetailBean" destroy-method="finalize">
<property name="jobClass" value="br.com.empresa.sistema.service.QuartzService" />
<property name="jobDataAsMap">
<map>
<entry key="alertaService" value-ref="alertaService" />
<entry key="avisoProgramaService" value-ref="avisoProgramaService" />
</map>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" destroy-method="destroy">
<property name="triggers">
<list>
<ref bean="cronTriggerAlerta" />
</list>
</property>
<property name="waitForJobsToCompleteOnShutdown" value="true" />
</bean>
<bean id="cronTriggerAlerta" class="org.springframework.scheduling.quartz.CronTriggerBean" destroy-method="clearAllTriggerListeners">
<property name="jobDetail" ref="quartzServiceAlerta" />
<property name="cronExpression" value="${cron.expression}" />
</bean>
e o Service está da seguinte forma.
public class QuartzService extends QuartzJobBean {
private AlertaService alertaService;
private AvisoProgramaService avisoProgramaService;
private Logger logger = Logger.getLogger(getClass());
public void setAlertaService(AlertaService alertaService) {
this.alertaService = alertaService;
}
public void setAvisoProgramaService(AvisoProgramaService avisoProgramaService) {
this.avisoProgramaService = avisoProgramaService;
}
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
JobExecutionContext jobContext = context;
logger.info("Criando Job de Aviso de Programas");
avisoProgramaService.execute();
logger.info("Criando Job de Alerta");
alertaService.execute();
try {
logger.info("Excluido Contexto");
context.getScheduler().getContext().clear();
jobContext.getScheduler().shutdown();
} catch (SchedulerException e) {
logger.fatal(e.getMessage());
}
}
}
Estive analisando o Log do Tomcat a única coisa que aparece é isto quando a restarta a aplicação, antes de parar simplesmente não tem nada somente o Log normal de execução e término de funcionamento da Job.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
Jan 11, 2013 6:27:17 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
Depois de um dia analisando e pesquisando descobri que não era o quartz meu problema e sim o sonar que esta no mesmo servidor e este quando terminava sua execução derrubava tudo.
Mais fica ai as configurações do quartz pra quem precisar!