无法启动Quartz Scheduler;嵌套异常是org.quartz.SchedulerConfigException:作业恢复期间发生故障

时间:2017-04-14 10:03:21

标签: spring quartz-scheduler tomcat8

上面错误的我的tomcat启动堆栈跟踪如下:

  

Apr 14, 2017 3:19:04 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.context.ApplicationContextException: Failed to start bean 'quartzRealTimeScheduler'; nested exception is org.springframework.scheduling.SchedulingException: Could not start Quartz Scheduler; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.JobPersistenceException: Couldn't retrieve trigger: null [See nested exception: java.io.OptionalDataException]] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176)

我在tomcat服务器上创建一个bean,在@configuration文件中启动。如下:

@Bean(name = "quartzRealTimeScheduler")
SchedulerFactoryBean schedulerFactoryBean() throws PropertyVetoException {
    LOG.info("Creating QUARTZ Scheduler for real time Job invocation");
    SchedulerFactoryBean factory = new SchedulerFactoryBean();
    factory.setQuartzProperties(getQuartzProperties());
    factory.setJobFactory(springBeanJobFactory());
    factory.setWaitForJobsToCompleteOnShutdown(true);
    factory.setApplicationContextSchedulerContextKey("applicationContext");
    return factory;
}

@Bean
public SpringBeanJobFactory springBeanJobFactory() {
    AutoWiringSpringBeanJobFactory jobFactory = new AutoWiringSpringBeanJobFactory();
    jobFactory.setApplicationContext(applicationContext);
    jobFactory.setIgnoredUnknownProperties("applicationContext");
    return jobFactory;
}

Quartz属性设置如下:

private Properties getQuartzProperties() {
    Organizations eeOrg = OrganizationMapper.getInstance().getBaseOrganization();
    Properties quartzProp = new Properties();
    quartzProp.put("org.quartz.jobStore.class" ,"org.quartz.impl.jdbcjobstore.JobStoreTX");
    quartzProp.put("org.quartz.jobStore.useProperties" ,true);
    quartzProp.put("org.quartz.scheduler.skipUpdateCheck" ,true);


    // Using DriverDelegate
    quartzProp.put("org.quartz.jobStore.driverDelegateClass" ,"org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");

    // Using datasource
    quartzProp.put("org.quartz.jobStore.dataSource" ,"qzDS");

    // Define the datasource to use
    quartzProp.put("org.quartz.dataSource.qzDS.driver" , env.getProperty(PROP_DEFAULT_DATA_SOURCE_DRIVER));
    quartzProp.put("org.quartz.dataSource.qzDS.URL" , eeOrg.getJdbcUrl());
    quartzProp.put("org.quartz.dataSource.qzDS.user" ,eeOrg.getJdbcUsername());
    quartzProp.put("org.quartz.dataSource.qzDS.password" , eeOrg.getJdbcPassword());
    quartzProp.put("org.quartz.scheduler.misfirePolicy", "doNothing");
    return quartzProp;
}

0 个答案:

没有答案