Quartz scheduler is failing to start the cron job
Posted
by Amit
on Stack Overflow
See other posts from Stack Overflow
or by Amit
Published on 2010-04-06T12:15:21Z
Indexed on
2010/04/06
12:23 UTC
Read the original article
Hit count: 897
java
|quartz-scheduler
Hi I am using Quartz scheduler to trigger a cron which needs to perform a host of activities. My Code for the same is as follow:
In the init() method of my InitServlet class, I am defining my TimerServer
public class InitServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
try {
System.out.println("Starting the CRON");
//Set the DSO Handler CRON
TimerServer task = TimerServer.getInstance();
task.setTask();
} catch (Exception ex) {
System.out.println("Failed to start the cron");
ex.printStackTrace();
}
}
In my TimerServer class I have the following methods
public void setTask() {
try{
this.setSubscriptionDailyJob();
} catch(SchedulerException ex) {
log.error("SchedulerException: "+ex.getMessage(), ex);
}
private void setSubscriptionDailyJob() throws SchedulerException {
log.info("Step 1 ");
Scheduler scheduler = schedulerFactory.getScheduler();
log.info("Step 2 ");
JobDetail subscriptionJob = new JobDetail("subscription", "subscriptiongroup", SubscriptionDaily.class);
log.info("Step 3 ");
// Initiate CronTrigger with its name and group name
CronTrigger subscriptionCronTrigger = new CronTrigger("subscriptionCronTrigger", "subscriptionTriggerGroup");
try {
log.info("Subscription cron: "+Constants.SUBSCRIPTION_CRON);
// setup CronExpression
CronExpression cexp = new CronExpression(Constants.SUBSCRIPTION_CRON);
// Assign the CronExpression to CronTrigger
subscriptionCronTrigger.setCronExpression(cexp);
} catch (Exception ex) {
log.warn("Exception: "+ex.getMessage(), ex);
}
scheduler.scheduleJob(subscriptionJob, subscriptionCronTrigger);
scheduler.start();
}
In my SubscriptionDaily class :
public class SubscriptionDaily implements Job {
public void execute(JobExecutionContext arg0) throws JobExecutionException {
//Actions to be performed
}
}
Now checking my logs, I am getting Step 1, Step 2 but not further.
My code is getting stucked at the TimerServer class itself. Logs wrt to Scheduler are :
17:24:43 INFO [TimerServer]: Step 1
17:24:43 INFO [SimpleThreadPool]: Job execution threads will use class loader of thread: http-8080-1
17:24:43 INFO [SchedulerSignalerImpl]: Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
17:24:43 INFO [QuartzScheduler]: Quartz Scheduler v.1.6.5 created.
17:24:43 INFO [RAMJobStore]: RAMJobStore initialized.
17:24:43 INFO [StdSchedulerFactory]: Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
17:24:43 INFO [StdSchedulerFactory]: Quartz scheduler version: 1.6.5 17:24:43 INFO [TimerServer]: Step 2
I think a log entry is missing : [QuartzScheduler]: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
Please help.
© Stack Overflow or respective owner