最近在做微信同步接口,用的quartz做的定时任务,同步的时候总是报下面一个错误。
错误代码
[ERROR][2017/06/13?09:49:00242][org.quartz.core.JobRunShell.run(JobRunShell.java:211)]
Job DEFAULT.wxMediaTokenJobDetail threw an unhandled Exception:
java.lang.NoSuchMethodError: org.quartz.JobExecutionException.<init>(Ljava/lang/String;Ljava/lang/Exception;Z)V
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:174)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
[DEBUG][2017/06/13?09:49:00246][org.quartz.utils.ExceptionHelper.supportsNestedThrowable(ExceptionHelper.java:97)]
Detected JDK support for nested exceptions.
NoSuchMethodError,感觉非常奇怪,配置文件里面的执行方法名并没有错误。更奇怪的是,有的任务能够执行成功,有的却报上面的错误了。
经过分析,应该是execute方法 里面报错了而没有捕捉,导致一层层向上抛出了异常。
为了验证猜想,重新建一个测试方法,
public void syncMedia() {
int zero = 0;
int test = 123 / zero;
System.out.println(test);
}
运行后,果然报了和上面一样的错。
检查execute里面的方法,发现查询语句有些问题,导致异常。。。
Over…