0

Quartz 1.8.3 および JBoss 7.1.1 を使用し、次のプロパティ ファイルを使用します。

#============================================================================
 # Configure Main Scheduler Properties
 #============================================================================
 org.quartz.scheduler.instanceName = MyScheduler
 org.quartz.scheduler.instanceId = AUTO
 #============================================================================
 # Configure ThreadPool
 #============================================================================
 org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
 org.quartz.threadPool.threadCount = 25
 org.quartz.threadPool.threadPriority = 5
 #============================================================================
 # Configure JobStore
 #============================================================================
 org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
 org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
 org.quartz.jobStore.useProperties = false
 org.quartz.jobStore.dataSource = quartzDS
 org.quartz.jobStore.nonManagedTXDataSource = quartzDSNoTx
 org.quartz.jobStore.tablePrefix = QRTZ_

 org.quartz.jobStore.clusterCheckinInterval = 20000
 org.quartz.jobStore.isClustered = false

 org.quartz.jobStore.acquireTriggersWithinLock=true

 #============================================================================
 # Configure Datasources  
 #============================================================================

 org.quartz.dataSource.quartzDS.jndiURL= java:jboss/datasources/myDS
 org.quartz.dataSource.quartzDSNoTx.jndiURL= java:jboss/datasources/myDS

 #============================================================================
 # Quartz Plugin
 #============================================================================
 org.quartz.plugin.jobstop.class = com.viagents.quartz.JobStopPlugin
 org.quartz.plugin.jobstop.tablePrefix = QRTZ_

Quartz を初期化する方法は、次のようなメソッドで @Singleton、@Startup、および @PostConstruct アノテーションを使用することです。

        @EjbInterface(type = EjbInterface.Type.LOCAL)
    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void startJobs() {

        try {

            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            this.registerJMX(scheduler);
            scheduler.start();


 ...........................................

 }

org.quartz.jobStore.isClustered プロパティが false の場合、スケジューラを取得できず、次の例外が発生します。

    13:20:23,636 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-15) Quartz Scheduler v.1.8.3 created.
 13:20:23,646 INFO  [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-15) Using db table-based data access locking (synchronization).
 13:20:23,682 INFO  [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-15) Removed 0 Volatile Trigger(s).
 13:20:23,684 INFO  [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-15) Removed 0 Volatile Job(s).
 13:20:23,687 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-15) Scheduler MyScheduler_$_NON_CLUSTERED shutting down.
 13:20:23,689 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-15) Scheduler MyScheduler_$_NON_CLUSTERED paused.
 13:20:23,691 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-15) Scheduler MyScheduler_$_NON_CLUSTERED shutdown complete.
 13:20:23,707 INFO  [stdout] (MSC service thread 1-15) java.lang.reflect.UndeclaredThrowableException
 13:20:23,709 INFO  [stdout] (MSC service thread 1-15)   at $Proxy33.rollback(Unknown Source)
 13:20:23,710 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreSupport.rollbackConnection(JobStoreSupport.java:3604)
 13:20:23,713 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3776)
 13:20:23,715 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3725)
 13:20:23,717 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreSupport.cleanVolatileTriggerAndJobs(JobStoreSupport.java:747)
 13:20:23,719 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:605)
 13:20:23,721 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.JobStoreCMT.initialize(JobStoreCMT.java:142)
 13:20:23,723 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1269)
 13:20:23,724 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1460)

 13:20:23,862 INFO  [stdout] (MSC service thread 1-15) Caused by: java.lang.reflect.InvocationTargetException
 13:20:23,865 INFO  [stdout] (MSC service thread 1-15)   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 13:20:23,866 INFO  [stdout] (MSC service thread 1-15)   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 13:20:23,868 INFO  [stdout] (MSC service thread 1-15)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 13:20:23,869 INFO  [stdout] (MSC service thread 1-15)   at java.lang.reflect.Method.invoke(Method.java:597)
 13:20:23,870 INFO  [stdout] (MSC service thread 1-15)   at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:71)
 13:20:23,872 INFO  [stdout] (MSC service thread 1-15)   ... 85 more
 13:20:23,873 INFO  [stdout] (MSC service thread 1-15) Caused by: java.sql.SQLException: You cannot rollback during a managed transaction!
 13:20:23,875 INFO  [stdout] (MSC service thread 1-15)   at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcRollback(BaseWrapperManagedConnection.java:1022)
 13:20:23,876 INFO  [stdout] (MSC service thread 1-15)   at org.jboss.jca.adapters.jdbc.WrappedConnection.rollback(WrappedConnection.java:778)
 13:20:23,878 INFO  [stdout] (MSC service thread 1-15)   ... 90 more
 13:20:23,880 INFO  [org.jboss.as] (MSC service thread 1-11) JBAS015951: Admin console listening on http://127.0.0.1:9990

クラスター プロパティを true に設定すると、次のようになります。

13:29:31,562 INFO  [org.quartz.core.QuartzScheduler] (MSC service thread 1-4) Scheduler meta-data: Quartz Scheduler (v1.8.3) 'ViSixdScheduler' with instanceId 'Se-PC1339507771533'
   Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
   NOT STARTED.
   Currently in standby mode.
   Number of jobs executed: 0
   Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 25 threads.
   Using job-store 'org.quartz.impl.jdbcjobstore.JobStoreCMT' - which supports persistence. and is clustered.
 13:29:31,579 INFO  [org.quartz.impl.StdSchedulerFactory] (MSC service thread 1-4) Quartz scheduler 'MyScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
 13:29:31,581 INFO  [org.quartz.impl.StdSchedulerFactory] (MSC service thread 1-4) Quartz scheduler version: 1.8.3
 13:29:33,577 INFO  [org.quartz.utils.UpdateChecker] (Timer-1) New Quartz update(s) found: 1.8.5 [http://www.terracotta.org/kit/reflector?kitID=default&pageID=QuartzChangeLog]
 13:29:43,970 INFO  [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-4) ClusterManager: detected 1 failed or restarted instances.
 13:29:43,972 INFO  [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-4) ClusterManager: Scanning for instance "Se-PC1339504980109"'s failed in-progress jobs.
 13:29:43,979 ERROR [org.quartz.impl.jdbcjobstore.JobStoreCMT] (MSC service thread 1-4) ClusterManager: Error managing cluster: null: java.lang.reflect.UndeclaredThrowableException
         at $Proxy33.commit(Unknown Source)      at org.quartz.impl.jdbcjobstore.JobStoreSupport.commitConnection(JobStoreSupport.java:3624) [quartz-1.8.3.jar:]
         at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3213) [quartz-1.8.3.jar:]
         at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3820) [quartz-1.8.3.jar:]

スケジューラーで start を呼び出さない場合、ジョブを起動できるのは @once だけです .... しかし、開始しないとまったく役に立ちません :(

どんな助けでも大歓迎です。

ありがとうございました

4

2 に答える 2

4

このクォーツ 2.0 チュートリアルを ご覧ください。

于 2012-06-28T11:53:44.617 に答える
2

あなたのquartzDSデータソースはstandalone.xmlでどのように定義されていますか?Quartz1.8.5とJboss7.1.1を使用すると、同じスタックトレースが表示されていたようです。クォーツデータソースのjta属性をfalseに設定した後、クォーツはエラーなしで起動しました。jtaをfalseに設定すると、単一のデータベースへのプレーンなJDBC接続のようになります。

<datasource jta="false" jndi-name="java:/quartzDS" pool-name="quartzDS" enabled="true" use-java-context="true" use-ccm="true">

.
于 2012-06-13T18:08:07.787 に答える