我在运行Quartz Schdular程序时遇到异常。
以下是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)
我已加入Quartz-1.7.2.jar
和
我的课程路径Quartz-all-1.7.2.jar
以及commom-logging 1.1.jar
和jdk 6
这是我从[JavaRanch] [1]
复制并粘贴的一个例子上页的第一个例子
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();
}
}
}
答案 0 :(得分:3)
您是否在源代码中编写了Job接口?
public interface Job {
void execute (JobExecutionContext ctx);
}
如果是这样,您不必这样做。 Quartz有自己的Job接口(在quartz.jar中)。 只保留你的RanchJob和RanchSchedule类,它应该可以工作。