我在java中集成quartz config xml和spring时遇到此异常

时间:2015-02-03 10:32:00

标签: java spring quartz-scheduler

我已经在数据库上创建了所需的qurtz表并正确映射了quartz xml的所有bean引用,但仍然得到异常。 我的quartzconfig.xml包含: -

<bean name="scheduler"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobFactory">
            <bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" />
        </property>
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager">
            <ref bean="transactionManager" />
        </property>
        <property name="quartzProperties">
            <props>
                <prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
                <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
                </prop>
                <prop key="org.quartz.jobStore.tablePrefix">qrtz_</prop>
                <prop key="org.quartz.jobStore.isClustered">true</prop>
                <prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
                <!-- <prop key="org.quartz.scheduler.instanceName">Scheduler</prop> -->
                <prop key="org.quartz.scheduler.instanceName">SgsClusteredScheduler</prop>
                <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
                <prop key="org.quartz.scheduler.jmx.export">true</prop>
            </props>
        </property>
        <property name="applicationContextSchedulerContextKey" value="applicationContext" />
        <property name="waitForJobsToCompleteOnShutdown" value="true" />
        <property name="overwriteExistingJobs" value="true" />
        <property name="triggers">

    <list>      

    <ref bean="companySaleUploaderJobTrigger" />

 </list>
</property>


    </bean>

例外

  

org.springframework.beans.factory.BeanCreationException:错误   在ServletContext资源中定义名为'scheduler'的bean   [/WEB-INF/config/quartzConfig.xml]:调用init方法失败;   嵌套异常是org.quartz.JobPersistenceException:无法存储   触发:   org.springframework.web.context.support.XmlWebApplicationContext [见   嵌套异常:java.io.NotSerializableException:   org.springframework.web.context.support.XmlWebApplicationContext] at   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)     在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)     在   org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:294)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)     在   org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)     在   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:591)     在   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)     在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469)     在   org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)     在   org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)     在   org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)     在   org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)     在   org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)     在   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)     在org.apache.catalina.core.StandardHost.start(StandardHost.java:840)     在   org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)     在   org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)     在   org.apache.catalina.core.StandardService.start(StandardService.java:525)     在   org.apache.catalina.core.StandardServer.start(StandardServer.java:754)     在org.apache.catalina.startup.Catalina.start(Catalina.java:595)at   sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)at   sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)at   java.lang.reflect.Method.invoke(未知来源)at   org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)at at   org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)引起   by:org.quartz.JobPersistenceException:无法存储触发器:   org.springframework.web.context.support.XmlWebApplicationContext [见   嵌套异常:java.io.NotSerializableException:   org.springframework.web.context.support.XmlWebApplicationContext]

1 个答案:

答案 0 :(得分:1)

由于jar的冲突而发生错误。现在我的问题是用两个罐解决。

当我使用 spring-3.1.2 release jar quartz-all-1.8.6.jar 时,我的代码工作正常,现在使用oracle数据库激活石英触发器

<强> Quartzconfig.xml

<bean name="scheduler"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="jobFactory">
            <bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" />
        </property>
        <property name="dataSource" ref="dataSource" />
        <property name="transactionManager">
            <ref bean="transactionManager" />
        </property>
        <property name="quartzProperties">          
                <props>
                <prop key="org.quartz.jobStore.misfireThreshold">6000000</prop>
                <prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>         
                <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
                </prop>
                <prop key="org.quartz.jobStore.tablePrefix">qrtz_</prop>
                <prop key="org.quartz.jobStore.isClustered">true</prop>
                <prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
                <!-- <prop key="org.quartz.scheduler.instanceName">Scheduler</prop> -->
                <prop key="org.quartz.scheduler.instanceName">SgsClusteredScheduler</prop>
                <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
                <prop key="org.quartz.scheduler.jmx.export">true</prop>
                <prop key="org.quartz.scheduler.skipUpdateCheck">true </prop>
            </props>

</property>
        <property name="applicationContextSchedulerContextKey" value="applicationContext" />
        <property name="waitForJobsToCompleteOnShutdown" value="true" />
        <property name="overwriteExistingJobs" value="true" />
        <property name="triggers">

    <list>      
    <ref bean="Emailschedule trigger" />

 </list>
</property>


    </bean>