Travis
Travis

Reputation: 705

Tables not being created for quartz plugin with Grails 2.3.11

I'm trying to enable job persistence using the quartz plugin for grails (http://grails.org/plugin/quartz) but everytime I try to create a new job it cannot find the table. It looks like the plugin isn't creating the tables.

The database I'm using in mysql and my grails version is 2.3.11. I've tried to mirror the configuration used in this blog (http://blog.robinpercy.com/2012/11/06/grails-clustered-quartz-configs-by-environment/) but the tables aren't being created.

Here is my quartz configuration :

jdbcProps = {
    scheduler.instanceName = "quartz"
    scheduler.instanceId = "AUTO"

    threadPool.class = "org.quartz.simpl.SimpleThreadPool"
    threadPool.threadCount = 3
    threadPool.threadPriority = 5

    jobStore.misfireThreshold = 60000

    jobStore.class = "org.quartz.impl.jdbcjobstore.JobStoreTX"
    jobStore.driverDelegateClass = "org.quartz.impl.jdbcjobstore.MSSQLDelegate"

    jobStore.useProperties = false
    jobStore.tablePrefix = "qrtz_"
    jobStore.isClustered = true
    jobStore.clusterCheckinInterval = 5000

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

}

environments {
development {
    quartz {
        autoStartup = true
        jdbcStore = true
        waitForJobsToCompleteOnShutdown = true
        props(jdbcProps)
    }
}
}

Quartz can find the database specified in my datasource.groovy file but it cannot find the tables it needs.

dataSource {
        pooled = true
        driverClassName = "com.mysql.jdbc.Driver"
        username = "root"
        password = "root"
        dbCreate = "create-drop" // one of 'create', 'create-drop','update'
        url = "jdbc:mysql://localhost:3306/appDatabase?autoReconnect=true"
        properties {
            numTestsPerEvictionRun=3
            testOnBorrow=true
            testWhileIdle=true
            testOnReturn=true
            validationQuery="SELECT 1"
         }
    }

Here is the exception

An error occurred while scanning for the next triggers to fire.
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Table 'appDatabase.qrtz_TRIGGERS' doesn't exist [See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'appDatabase.qrtz_TRIGGERS' doesn't exist

Am I missing something here? Do I need to manually create the tables or do I have some configuration error?

Upvotes: 1

Views: 1511

Answers (1)

Burt Beckwith
Burt Beckwith

Reputation: 75681

I haven't used this in a while, but I doubt it will create tables for you. The Quartz distro comes with DDL for over 20 databases in the docs/dbTables directory, so you would use the file for your database and version, and customize as needed before running them.

I did a conference talk a few years ago that included clustering Quartz and included an automated way to use Hibernate cfg.xml and hbm.xml files to create the tables. You can download the sample app and use that same approach - it'll still work with Hibernate 3 and should with Hibernate 4, but might require an update to the <!DOCTYPE ...> in the xml.

Upvotes: 3

Related Questions