Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin is not working with Grails 5 #115

Open
bruno-lopes opened this issue Jan 3, 2022 · 7 comments
Open

Plugin is not working with Grails 5 #115

bruno-lopes opened this issue Jan 3, 2022 · 7 comments

Comments

@bruno-lopes
Copy link

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.

@mcable01
Copy link

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

@jglapa
Copy link

jglapa commented Jan 30, 2022

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 spring-projects/spring-framework#27709 (comment)

@sagrawal31
Copy link

Any update here? Is the plugin no longer maintained?

@puneetbehl
Copy link
Contributor

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.

@sagrawal31
Copy link

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

@sagrawal31
Copy link

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 😔

@kaymanov-emitter
Copy link

kaymanov-emitter commented Mar 20, 2023

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants