0

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>
4

1 に答える 1

0

この部分を取り出してみてください:

 <property name="jobDetails">
            <list>
                <ref bean="runScheduleJob" />
            </list>
        </property>

トリガーで jobDetails を定義します。

于 2013-04-30T20:28:55.897 に答える