我有 2 个不同的触发器和 2 个不同的工作。TimeLord1 和 TimeLord2 是同时处理的 2 个不同的 Java 类,延迟相同,但它们是不同的类。
仅供参考,TimeLord 课程没有任何问题。
我得到了这个例外:
堆栈跟踪
ERROR JobRunShell: Job DEFAULT.runScheduleJob1 threw an unhandled Exception:
java.lang.NullPointerException
at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,736 [] ERROR JobRunShell: Job DEFAULT.runScheduleJob2 threw an unhandled Exception:
java.lang.NullPointerException
at service.quartz.RunScheduleJob.executeInternal(RunScheduleJob.java:17)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:113)
at org.quartz.core.JobRunShell.run(JobRunShell.java:199)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
15:56:17,738 [] ERROR ErrorLogger: Job (DEFAULT.runScheduleJob1 threw an exception.
org.quartz.SchedulerException: Job threw an unhandled exception. [See nested exception: java.lang.NullPointerException]
at org.quartz.core.JobRunShell.run(JobRunShell.java:210)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
代码
<bean name="runScheduleJob1" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="service.quartz.RunScheduleJob" />
<property name="jobDataAsMap">
<map>
<entry key="runScheduleTask1" value-ref="timeLord1" />
</map>
</property>
</bean>
<bean name="runScheduleJob2" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="service.quartz.RunScheduleJob" />
<property name="jobDataAsMap">
<map>
<entry key="runScheduleTask2" value-ref="timeLord2" />
</map>
</property>
</bean>
<bean id="simpleTrigger1"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="runScheduleJob1" />
<property name="repeatInterval" value="500" />
<property name="startDelay" value="10" />
</bean>
<bean id="simpleTrigger2"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="runScheduleJob2" />
<property name="repeatInterval" value="500" />
<property name="startDelay" value="10" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="jobDetails">
<list>
<ref bean="runScheduleJob" />
</list>
</property>
<property name="triggers">
<list>
<ref bean="simpleTrigger1" />
<ref bean="simpleTrigger2" />
</list>
</property>
</bean>