使用jdbcStore Grails Quartz Plugin错误

时间:2013-12-18 20:05:05

标签: grails quartz-scheduler grails-plugin

我尝试使用Grails的最新石英插件:quartz:1.0.1。

如果我离开jdbcStore = false则有效,如果设置为true则失败。 QuartzConfig.groovy:

    quartz {
       autoStartup = true
       jdbcStore = true
       waitForJobsToCompleteOnShutdown = true
       exposeSchedulerInRepository = false

    props {
        scheduler.skipUpdateCheck = true
     }
    }

这是属性文件:

    org.quartz.scheduler.instanceName reporting_test
    org.quartz.scheduler.instanceId AUTO

    org.quartz.threadPool.class org.quartz.simpl.SimpleThreadPool
    org.quartz.threadPool.threadCount 5
    org.quartz.threadPool.threadPriority 5

    org.quartz.jobStore.misfireThreshold 60000

    org.quartz.jobStore.class org.quartz.impl.jdbcjobstore.JobStoreTX
    org.quartz.jobStore.driverDelegateClass org.quartz.impl.jdbcjobstore.StdJDBCDelegate

    org.quartz.jobStore.useProperties false
    org.quartz.jobStore.tablePrefix QRTZ_
    org.quartz.jobStore.isClustered true
    org.quartz.jobStore.clusterCheckinInterval 5000

    org.quartz.plugin.shutdownhook.class org.quartz.plugins.management.ShutdownHookPlugin
    org.quartz.plugin.shutdownhook.cleanShutdown true

我一直在尝试使用Datasource设置,因为我更喜欢在Datasource.groovy中使用我的默认DS设置。无论数据源的设置如何,我在启动时仍会收到以下错误消息。

        2013-12-18 13:43:14,693 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error initializing the application: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR. [See nested exception: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.]
        org.codehaus.groovy.runtime.InvokerInvocationException: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR. [See nested exception: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.]
            at java.util.concurrent.FutureTask.run(FutureTask.java:262)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
            at java.lang.Thread.run(Thread.java:744)
        Caused by: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR. [See nested exception: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.]
            at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157)
            at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113)
            at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:238)
            at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeJob(JobStoreSupport.java:1086)
            at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:969)
            at org.quartz.core.QuartzScheduler.addJob(QuartzScheduler.java:958)
            at org.quartz.impl.StdScheduler.addJob(StdScheduler.java:268)
            at QuartzGrailsPlugin.scheduleJob(QuartzGrailsPlugin.groovy:268)
            at QuartzGrailsPlugin$_closure5_closure23.doCall(QuartzGrailsPlugin.groovy:248)
            at QuartzGrailsPlugin$_closure5.doCall(QuartzGrailsPlugin.groovy:247)
            ... 4 more
        Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Line 1: FOR UPDATE clause allowed only for DECLARE CURSOR.
            at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
            at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
            at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:96)
            ... 13 more

这些表存在于我的数据库中。我实际上是将它们与quartz2插件一起用于grails,但出于各种原因决定试用这个插件。

关于我设置错误的任何想法?

1 个答案:

答案 0 :(得分:6)

找到答案。

正在运行一个查询来锁定行,在这种情况下失败时是:

SELECT * FROM QRTZ_LOCKS WHERE SCHED_NAME = 'reporting_test' AND LOCK_NAME = 'STATE_ACCESS' FOR UPDATE

FOR UPDATE不适用于MSSQL数据库。我发现我使用了错误的代表。我将我的财产改为:

org.quartz.jobStore.driverDelegateClass org.quartz.impl.jdbcjobstore.MSSQLDelegate

这很有效,希望这有助于其他人。