Reputation: 39551
I am getting he following Exception while running my Quartz Schdular program.
Below is the exception Trace
Mar 26, 2010 2:54:24 PM org.quartz.core.QuartzScheduler start
INFO: Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
Exception in thread "main" java.lang.IllegalArgumentException: Job class must implement the Job interface.
at org.quartz.JobDetail.setJobClass(JobDetail.java:291)
at org.quartz.JobDetail.<init>(JobDetail.java:138)
at com.Quarrtz.RanchSchedule.main(RanchSchedule.java:18)
I have included Quartz-1.7.2.jar
and
Quartz-all-1.7.2.jar
in my class path along with commom-logging 1.1.jar
and jdk 6
this is an example i have copy and pasted from [JavaRanch][1]
First example in the above page
public interface Job {
void execute (JobExecutionContext ctx);
}
public class RanchJob implements Job {
public void execute (JobExecutionContext ctx) throws JobExecutionException {
System.out.println("[JOB] Welcome at JavaRanch");
}
}
public class RanchSchedule {
public static void main (String[] args) {
try {
SchedulerFactory factory = new org.quartz.impl.StdSchedulerFactory();
Scheduler scheduler = factory.getScheduler();
scheduler.start();
JobDetail jobDetail = new JobDetail("ranchJob", null, RanchJob.class);
// Fires every 10 seconds
Trigger ranchTrigger = TriggerUtils.makeSecondlyTrigger(10);
ranchTrigger.setName("ranchTrigger");
scheduler.scheduleJob(jobDetail, ranchTrigger);
} catch (SchedulerException ex) {
ex.printStackTrace();
}
}
}
Upvotes: 0
Views: 6453
Reputation: 556
Have you written the Job interface in your source code ?
public interface Job {
void execute (JobExecutionContext ctx);
}
If so, you don't have to do this. Quartz has its own Job interface (in the quartz.jar). Keep only your RanchJob and RanchSchedule classes and it should work.
Upvotes: 3