Quartz属性不会触发Quartz Job [英] Quartz properties does not trigger Quartz Job

查看:81
本文介绍了Quartz属性不会触发Quartz Job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Quartz 2.1.3. 我的quartz.properties:

I'm using Quartz 2.1.3. My quartz.properties:

#===================================================
# Configure the Job Initialization Plugin
#===================================================

org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-jobs.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.scanInterval = 10
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false

我的quart-jobs.xml:

<?xml version='1.0' encoding='utf-8'?>
<job-scheduling-data xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
  version="1.8">

    <schedule>
        <job>
            <name>myjob</name>
            <group>MYJOBGROUP</group>

            <description>Job to Test</description>
            <job-class>com.upd.test.TestQuartz</job-class>
            <trigger>
            <cron>
                <name>my-trigger</name>
                <group>MYTRIGGER_GROUP</group>
                <job-name>myjob</job-name>

                <job-group>MYJOBGROUP</job-group>
                <cron-expression>0/5 * * * * ?</cron-expression>

            </cron>
        </trigger>
    </schedule>
</job-scheduling-data>

我的web.xml:

<context-param>
         <param-name>quartz:config-file</param-name>
         <param-value>quartz.properties</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:shutdown-on-unload</param-name>
         <param-value>true</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:wait-on-shutdown</param-name>
         <param-value>false</param-value>
     </context-param>
     <context-param>
         <param-name>quartz:start-scheduler-on-load</param-name>
         <param-value>true</param-value>
     </context-param>

<listener>
         <listener-class>
             org.quartz.ee.servlet.QuartzInitializerListener
         </listener-class>
     </listener>

我的TestQuartz课:

package com.upd.test;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestQuartz implements Job{
    private Logger logger = LoggerFactory.getLogger(TestQuartz.class);
    public void printMe() {
        logger.trace("Run Me");
    }   

    public void execute(JobExecutionContext arg0) throws JobExecutionException {
        printMe();
    }
}

我放在\WEB-INF\classes下的

quartz.propertiesquartz-jobs.xml 当tomcat启动时,我从日志中看到的唯一内容是:

quartz.properties and quartz-jobs.xml I put under \WEB-INF\classes When tomcat starts, the only thing I see from the log is:

(org.quartz.ee.servlet.QuartzInitializerListener:147) - Quartz Initializer Servlet loaded, initializing Scheduler...
(org.quartz.ee.servlet.QuartzInitializerListener:264) - Quartz Scheduler successful shutdown.

quartz-jobs.xml似乎不是由quartz.properties触发的.我在这里做错什么了吗? 任何答复都非常感谢.谢谢!

It seems like the quartz-jobs.xml is not triggered by the quartz.properties. I do anything wrong here? Any reply is much appreciated. Thank you!

已解决:

- Add threadpool defined in `quartz.properties`.

- Download jta-1.1.jar.

感谢您的评论!

推荐答案

Quartz Scheduler successful shutdown.

消息在整个应用程序关闭时出现,您是否在启动过程中立即看到此消息?这意味着调度程序甚至没有运行.还要确保加载了quartz.properties文件.故意在quartz.properties或quart-jobs.xml中执行语法错误(使用不正确的插件类名称,在开头添加一些虚假文字...)

message appears when the whole application shuts down, are you seeings this immediately during startup? This means the scheduler isn't even running. Also make sure quartz.properties file is loaded. Intentionally do a grammar error in quartz.properties or quart-jobs.xml (use incorrect plugin class name, add some bogus text at the beginning...)

这篇关于Quartz属性不会触发Quartz Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆