gpt4 book ai didi

java - 在 java 中集成quartz config xml 和 spring 时出现此异常

转载 作者:行者123 更新时间:2023-12-01 11:57:47 25 4
gpt4 key购买 nike

我已经在数据库上创建了所需的 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: Error creating bean with name 'scheduler' defined in ServletContext resource [/WEB-INF/config/quartzConfig.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store trigger: org.springframework.web.context.support.XmlWebApplicationContext [See nested exception: java.io.NotSerializableException: org.springframework.web.context.support.XmlWebApplicationContext] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:591) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:469) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: org.quartz.JobPersistenceException: Couldn't store trigger: org.springframework.web.context.support.XmlWebApplicationContext [See nested exception: java.io.NotSerializableException: org.springframework.web.context.support.XmlWebApplicationContext]

最佳答案

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

当我将spring-3.1.2release jarquartz-all-1.8.6.jar一起使用时,我的代码工作正常,现在 quartz 触发器与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>

关于java - 在 java 中集成quartz config xml 和 spring 时出现此异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28296698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com