apache / apache/grails-core

Create Quartz Tables in Bootstrap

Open
#16,194 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-quartz
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

I am using quartz plugin version 2.0.12 and Grails 3.2.11 and I am wanting to create the required quartz tables in the bootstrap init with jdbcStore = true in the quartz config. I need to find a way to do this so when I clone an amazon instances of my application in AWS I don't have to manually create the quartz tables every time I clone the instance. The problem I am having is the the quartz plugin is initializing and trying to read from the QRTZ_JOB_DETAILS table before the table is even created in my bootstrap so the application fails to run with the following stacktrace:

`[02/07/2018 15:49:21] ERROR : org.springframework.boot.SpringApplication : Application startup failed
org.quartz.JobPersistenceException: Couldn't obtain job names: Table "QRTZ_JOB_DETAILS" not found; SQL statement:
SELECT JOB_NAME, JOB_GROUP FROM QRTZ_JOB_DETAILS WHERE SCHED_NAME = 'quartzScheduler' AND JOB_GROUP LIKE ? [42102-194]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getJobNames(JobStoreSupport.java:1889)
...
at org.quartz.impl.jdbcjobstore.JobStoreSupport.getJobNames(JobStoreSupport.java:1887)
... 35 more

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootRun'.`

My bootstrap looks like this:
`
class BootStrap {

def dataSource

def init = { servletContext ->

def queries = []

queries.add("CREATE TABLE if not exists qrtz_job_details ( " +
"SCHED_NAME VARCHAR(120) NOT NULL," +
"JOB_NAME VARCHAR(200) NOT NULL," +
"JOB_GROUP VARCHAR(200) NOT NULL," +
"DESCRIPTION VARCHAR(250) NULL," +
"JOB_CLASS_NAME VARCHAR(250) NOT NULL," +
"IS_DURABLE BOOLEAN NOT NULL," +
"IS_NONCONCURRENT BOOLEAN NOT NULL," +
"IS_UPDATE_DATA BOOLEAN NOT NULL," +
"REQUESTS_RECOVERY BOOLEAN NOT NULL," +
"JOB_DATA BINARY NULL," +
"PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)" +
");")

Sql sql = new Sql(dataSource)

queries.each { query ->
sql.execute(query)
}

sql.close()
}

}
`

Is there a way to automatically generate the quartz tables in any way without manual intervention?

Contributor guide

Open the contributing guide

Research direction

Start with the BootStrap init closure and the Quartz plugin initialization path described in the issue, focusing on why QRTZ_JOB_DETAILS is queried before bootstrap runs. Check how jdbcStore startup and table creation interact. Done means a cloned AWS instance can start with the required Quartz tables created automatically, without manual intervention.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.