DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Listening For Exception Thrown During The Execution Of A Quartz Job In Spring
Code of the exception listener :
package some.package;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.listeners.JobListenerSupport;
public class JobExecutionExceptionListener extends JobListenerSupport {
public String getName() {
return "JobExecutionExceptionListener";
}
@Override
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
if (jobException != null) {
// handle exception
}
}
}
Spring configuration :
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <!-- other properties --> <property name="globalJobListeners"> <list> <bean class="some.package.JobExecutionExceptionListener"/> </list> </property> </bean>




