2012-03-07 118 views
1

我正在使用Quartz 2.1.3。 我quartz.properties石英屬性不會觸發Quartz Job

#=================================================== 
# 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(); 
    } 
} 

quartz.propertiesquartz-jobs.xml我把\WEB-INF\classes 下,當Tomcat啓動時,我從日誌中看到的僅僅是:

(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觸發。我在這裏做錯了什麼? 任何答覆,非常感謝。謝謝!

解決:

- Add threadpool defined in `quartz.properties`. 

- Download jta-1.1.jar. 

感謝您的評論!

+0

我檢查tomcat std log,問題是沒有定義threadpool在屬性文件和缺乏事務類。只需下載jta-1.1.jar,那麼現在一切正常。不管怎麼說,還是要謝謝你! – baizen 2012-03-07 08:27:22

回答

1
Quartz Scheduler successful shutdown. 

當整個應用程序關閉時出現消息,您是否在啓動過程中立即看到此消息?這意味着調度程序甚至沒有運行。還要確保quartz.properties文件已加載。有意在quartz.properties或quart-jobs.xml中做了一個語法錯誤(使用不正確的插件類名,在開頭添加一些假文字...)

+0

兩個文件都加載成功,唯一缺少的就是jta-1.1.jar,並修改quartz.properties的一些屬性!謝謝 :) – baizen 2012-03-07 08:31:07