运行 Quartz Scheduler 程序时出现异常
我在运行我的 Quartz Schdular 程序时遇到异常。
异常跟踪
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();
}
}
}
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
andQuartz-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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在源代码中编写了 Job 接口吗?
如果是这样,您不必这样做。 Quartz 有自己的 Job 接口(在quartz.jar 中)。
只保留 RanchJob 和 RanchSchedule 类,它应该可以工作。
Have you written the Job interface in your source code ?
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.