但是任务还是继续跑着
2016-3-11 10:36:15 org.quartz.core.ErrorLogger schedulerError
严重: Unable to notify JobListener(s) of Job that was executed: (error will be ignored). trigger= group2.guanbi job= group2.job2
org.quartz.SchedulerException: JobListener 'dummyJobListenerName' threw exception: null [See nested exception: java.lang.NullPointerException]
at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1987)
at org.quartz.core.JobRunShell.notifyJobListenersComplete(JobRunShell.java:340)
at org.quartz.core.JobRunShell.run(JobRunShell.java:224)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.NullPointerException
at test1.HelloJobListener.jobWasExecuted(HelloJobListener.java:37)
at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1985)
... 3 more
下面是报错类的代码
public class HelloJobListener implements JobListener {
public static final String LISTENER_NAME = "dummyJobListenerName";
@Override
public String getName() {
// TODO Auto-generated method stub
return LISTENER_NAME;
}
@Override
public void jobToBeExecuted(JobExecutionContext context) {
String jobName = context.getJobDetail().getKey().toString();
System.out.println("jobToBeExecuted");
System.out.println("Job : " + jobName + " is going to start...");
}
@Override
public void jobExecutionVetoed(JobExecutionContext context) {
System.out.println("jobExecutionVetoed");
}
@Override
public void jobWasExecuted(JobExecutionContext context,
JobExecutionException jobException) {
System.out.println("jobWasExecuted");
String jobName = context.getJobDetail().getKey().toString();
System.out.println("Job : " + jobName + " is finished...");
if (!jobException.getMessage().equals("")) {
System.out.println("Exception thrown by: " + jobName
+ " Exception: " + jobException.getMessage());
}
}
}
JobListener'dummyJobListenerName'threwexception:null[Seenestedexception:java.lang.NullPointerException]
抛出的是空指针异常,建议断点跟进去看看哪里的get方法报错。
Causedby:java.lang.NullPointerException
attest1.HelloJobListener.jobWasExecuted(HelloJobListener.java:37)
第37行是什么?
关于spring和quartz的配置和使用,可参考:http://git.oschina.net/wangkang/llsfw
希望能够帮到你.
断点,attest1.HelloJobListener.jobWasExecuted(HelloJobListener.java:37)第37行报空指针。
StringjobName=context.getJobDetail().getKey().toString();
这行空指针错误,加个点点看看你的context是不是null,或者context.getJobDetail()是不是null
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。