我正在使用Quartz调度程序的DB Job Store来定期运行我的运行。为了获得所有现有的作业及其状态,我使用以下代码:
for(String jobGroupName : scheduler.getJobGroupNames() {
for(String jobName : scheduler.getjobNames(jobGroupName) {
JobDetail jobDetail = scheduler.getJobDetail(jobName, jobGroupName);
Trigger[] triggers = scheduler.getTriggersOfJob(jobName, jobGroupName);
Trigger trigger = triggers[0];
int jobState = scheduler.getTriggerState(trigger.getName(), trigger.getGroup());
}
}
我还实现了如下的作业界面
public class jobImpl implements Job {
public void execute(JobExecutionContext arg) {
// My Code
}
}
当我调用代码获取现有的Jobs及其状态(第一个代码示例)时,jobImpl中的execute方法被触发。
有人可以帮我解决这个问题吗?
@Tomasz
这是堆栈跟踪:
java.lang.NullPointerException
[junit] at com.JobImpl.execute(JobImpl.java:24)
[junit] at org.quartz.core.JobRunShell.run(JobRunShell.java:216)
[junit] at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)