spring+quartz启动报错

关注 发布于 2011/03/18 12:46
阅读 20K+
收藏 0

解读下一代网络:算力网络正从理想照进现实!>>>

如上代码和配置,启动tomcat报严重错误

2011-3-18 12:44:46 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springNonTxDataSource.org.springframework.scheduling.quartz.SchedulerFactoryBean#0': java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool' [See nested exception: java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool']]
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
 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:291)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
 at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
 at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
 at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)
 at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
 at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
 at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
 at java.util.concurrent.FutureTask.run(FutureTask.java:138)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
 at java.lang.Thread.run(Thread.java:662)
Caused by: org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springNonTxDataSource.org.springframework.scheduling.quartz.SchedulerFactoryBean#0': java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool' [See nested exception: java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool']]
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:607)
 at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize(JobStoreCMT.java:142)
 at org.springframework.scheduling.quartz.LocalDataSourceJobStore.initialize(LocalDataSourceJobStore.java:151)
 at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1274)
 at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1465)
 at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:600)
 at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:481)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
 ... 20 more
Caused by: org.quartz.JobPersistenceException: Failed to obtain DB connection from data source 'springNonTxDataSource.org.springframework.scheduling.quartz.SchedulerFactoryBean#0': java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool' [See nested exception: java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool']
 at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:165)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3753)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3725)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.cleanVolatileTriggerAndJobs(JobStoreSupport.java:747)
 at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:605)
 ... 28 more
Caused by: java.sql.SQLException: org.logicalcobwebs.proxool.ProxoolException: Attempt to refer to a unregistered pool by its alias 'DBPool'
 at org.logicalcobwebs.proxool.ProxoolDriver.connect(ProxoolDriver.java:109)
 at java.sql.DriverManager.getConnection(DriverManager.java:582)
 at java.sql.DriverManager.getConnection(DriverManager.java:154)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:173)
 at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:164)
 at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149)
 at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119)
 at org.springframework.scheduling.quartz.LocalDataSourceJobStore$2.getConnection(LocalDataSourceJobStore.java:129)
 at org.quartz.utils.DBConnectionManager.getConnection(DBConnectionManager.java:109)
 at org.quartz.impl.jdbcjobstore.JobStoreCMT.getNonManagedTXConnection(JobStoreCMT.java:162)
 ... 32 more
2011-3-18 12:44:46 org.apache.catalina.core.StandardContext startInternal
严重: Error listenerStart
2011-3-18 12:44:46 org.apache.catalina.core.StandardContext startInternal
严重: Context [/webxxts] startup failed due to previous errors
2011-3-18 12:44:46 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/webxxts] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/webxxts] registered the JDBC driver [org.logicalcobwebs.proxool.ProxoolDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-1] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-2] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-3] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-4] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-5] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-6] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-7] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-8] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-9] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/webxxts] appears to have started a thread named [org.springframework.scheduling.quartz.SchedulerFactoryBean#0_Worker-10] but has failed to stop it. This is very likely to create a memory leak.
2011-3-18 12:44:46 org.apache.coyote.AbstractProtocolHandler start
信息: Starting ProtocolHandler ["http-apr-8080"]
2011-3-18 12:44:46 org.apache.catalina.startup.Catalina start
信息: Server startup in 4313 ms

加载中
0
关注
关注

package com.job;

public class MatchSmsOpenJob {
 public void execute(){
  System.out.println("do it...");
 }
}

0
红薯
红薯

配置错,无法获取数据库连接

Failed to obtain DB connection from data source

0
关注
关注

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns:mvc="http://www.springframework.org/schema/mvc"
 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
 default-lazy-init="false" default-autowire="byName">
 <!-- 数据源配置 -->
 <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
     <property name="driverClassName">
         <value>org.logicalcobwebs.proxool.ProxoolDriver</value>
     </property>
     <property name="url">
         <value>proxool.DBPool</value>
     </property>
 </bean> <!-- 事物配置 -->
 <bean id="transactionManager"
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
 </bean>
 <!-- 使用 annotation 自动注入bean,并检查@Required、@Autowired的属性已被注入-->
 <context:component-scan base-package="com" />
 <!-- JdbcTemplate 用于批量操作  -->
 <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
  <property name="dataSource" ref="dataSource" />
 </bean>
 <!-- Creates the JSR-303 Validator --> 
 <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
 
 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
     <property name="webBindingInitializer">
         <!-- Configures Spring MVC DataBinder instances -->
         <bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
             <property name="validator" ref="validator" />
         </bean>
     </property>
 </bean>
 <!-- 定时任务 -->
 <bean id="matchSmsOpenJob" class="com.job.MatchSmsOpenJob" />
 <bean id="matchSmsOpenJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  <property name="targetObject" ref="matchSmsOpenJob"/>
  <property name="targetMethod" value="execute"/>
  <property name="concurrent" value="false"/>
 </bean>
 <bean id="matchSmsOpenTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
  <property name="jobDetail" ref="matchSmsOpenJobDetail"/>
  <property name="cronExpression" value="*/5 * * * * ?"/>
 </bean>
 <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="default" autowire="default">
  <property name="triggers">
   <list>
    <ref bean="matchSmsOpenTrigger"/>
   </list>
  </property>
  <property name="autoStartup" value="true"/>
 </bean>
</beans>

0
关注
关注

去掉最后的定时任务就正常

0
关注
关注

package com.job;

public class MatchSmsOpenJob {
 public void execute(){
  System.out.println("do it...");

怎么操作数据库????
 }
}

0
关注
关注

配置有冲突,启动起来了,不知道怎么操作库了???

0
关注
关注

搞定了,谢谢各位,和平常一样的操作

0
r
rancococ
和哪些配置有冲突,麻烦交流一下, rancococ@hotmail.com
0
光石头
光石头
估计是因为你的 dataSource 命名,spring自动吧这个dataSource注入到 quartz了
0
t
thxktv
是哪里冲突呢  我也遇到同样的问题
返回顶部
顶部