Plugin is not working with Grails 5
First of all, very thanks for this nice plugin! I was using it with Grails 4, and it worked like a charm. Now, I've updated Grails version to 5.1.1, and it stopped working. When I try to run the application, I get the following error:
2022-01-03 12:20:04.915 ERROR --- [ restartedMain] o.s.boot.SpringApplication : [ - ] Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler': Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: DataSource name not set.
Are there any workaround to set the DataSource name? Thanks in advance.
This looks like my issue when upgrading my application to 5.1.1 This is how I corrected the error, I Included this in my build.gradle file.
implementation 'org.quartz-scheduler:quartz:2.2.1' // Is not pulled in by default
Please try setting this in the application.groovy (yml) (apart adding the dependency already mentioned):
quartz.jobStore.'class' = 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' // previosly 'org.quartz.impl.jdbcjobstore.JobStoreTX'
more info here https://github.com/spring-projects/spring-framework/issues/27709#issuecomment-975661609
Any update here? Is the plugin no longer maintained?
Could you please verify if solutions suggested above in the previous comment by works or NOT?
I didn't get a chance to work on the plugin yet. I would appreciate if someone from the community try to help with the upgrade that way I will able to quickly push out a release soon.
Yes, I have already been using the followings with my Grails 4.x version and it has been working fine for a year-
implementation("org.quartz-scheduler:quartz:2.3.2") {
exclude group: "slf4j-api", module: "c3p0"
}
After upgrading to Grails 5.2.3, I don't see any errors but the jobs aren't getting triggered.
When I'm adding quartz.jobStore.'class' = 'org.springframework.scheduling.quartz.LocalDataSourceJobStore', I'm getting the following exception-
2022-12-27 15:29:03.726 DEBUG [ restartedMain] org.mongodb.driver.connection : Closing connection connectionId{localValue:2, serverValue:2}
2022-12-27 15:29:03.776 ERROR [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler': Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: No local DataSource found for configuration - 'dataSource' property must be set on SchedulerFactoryBean
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:936)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
at grails.boot.GrailsApp.run(GrailsApp.groovy:485)
at grails.boot.GrailsApp.run(GrailsApp.groovy:472)
at com.letscooee.Application.main(Application.groovy:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.quartz.SchedulerConfigException: No local DataSource found for configuration - 'dataSource' property must be set on SchedulerFactoryBean
at org.springframework.scheduling.quartz.LocalDataSourceJobStore.initialize(LocalDataSourceJobStore.java:97)
at org.quartz.impl.StdSchedulerFactory.instantiate(StdSchedulerFactory.java:1368)
at org.quartz.impl.StdSchedulerFactory.getScheduler(StdSchedulerFactory.java:1579)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.createScheduler(SchedulerFactoryBean.java:679)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.prepareScheduler(SchedulerFactoryBean.java:616)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
... 22 common frames omitted
Hey, I apologise.
Actually, this is not an issue for me. Job is working fine for me on Grails 5.2.3. I had an immediate statement in my execute method-
def execute() {
if (KernelUtils.isLocalEnvironment()) {
log.debug "Not executing ${this.class.name} in local environment"
return
}
...
}
Sorry for the noise 😔
I'm having the same issue on Grails 5.2.3 (I've upgraded from Grails 2 and now no jobs are being triggered) with the following dependencies:
implementation('org.quartz-scheduler:quartz:2.3.2') {
exclude group: 'slf4j-api', module: 'c3p0'
}
implementation 'org.grails.plugins:quartz:2.0.13'
I have a lot of jobs and triggers registered at startup like this:
Trigger createTrigger(FirstmoverExport export) {
try {
Trigger trigger = new CronTriggerImpl(triggerName(export), TRIGGER_GROUP, export.cron)
trigger.jobDataMap.putAll([desc: "First mover export - ${export.id} - ${export.cron}", id: export.id])
return trigger
} catch (all) {
log.error "cannot create first mover trigger with ${export.id} and ${export.cron}"
return null
}
}
All of this happens without error but all of the jobs and triggers are empty when I try to debug:
def jobGroupNames = quartzScheduler.getJobGroupNames()
def triggerGroupNames = quartzScheduler.getTriggerGroupNames()
Grails 5 use Gradle 7.x
https://docs.grails.org/5.3.6/guide/upgrading.html#upgrading40x
Compile dependency configuration as well as others have been removed from Gradle 7.x. In previous version they were deprecated.
Need convert branch 2.0.x build.gradle configurations and create new branch 2.1.x for support Grails 5.