grails-quartz icon indicating copy to clipboard operation
grails-quartz copied to clipboard

Cannot get property jobKey

Open xpusostomos opened this issue 1 year ago • 4 comments

I've got an app that's been running fine in production for quite a while. Recently I decided to do some development on Windows instead of Linux and I get the following crash when running on Windows, both in intellij and when run as a war. It's exactly the same source code either way, and I've done tons of grails development on Windows before, so I'm a bit stumped... maybe someone will have some clue what's going on

java.lang.NullPointerException: Cannot get property 'jobKey' on null object
	at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:60)
	at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190)
	at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:46)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:329)
	at grails.plugins.quartz.QuartzJob$Trait$Helper.schedule(QuartzJob.groovy:59)
	at grails.plugins.quartz.QuartzJob$Trait$Helper$schedule$2.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:157)
	at org.grails.plugins.asyncmail.AsyncMailJob.schedule(AsyncMailJob.groovy)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:44)
	at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:89)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at grails.plugins.quartz.QuartzJob$Trait$Helper.schedule(QuartzJob.groovy)
	at grails.plugins.quartz.QuartzJob$Trait$Helper$schedule$1.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at org.grails.plugins.asyncmail.AsyncMailJob.schedule(AsyncMailJob.groovy)
	at org.grails.plugins.asyncmail.AsyncMailJob$schedule.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
	at org.grails.plugins.asyncmail.AsyncMailGrailsPlugin.startJobs(AsyncMailGrailsPlugin.groovy:59)
	at org.grails.plugins.asyncmail.AsyncMailGrailsPlugin$startJobs.callCurrent(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
	at org.grails.plugins.asyncmail.AsyncMailGrailsPlugin.onStartup(AsyncMailGrailsPlugin.groovy:29)
	at org.grails.plugins.AbstractGrailsPluginManager.onStartup(AbstractGrailsPluginManager.java:345)
	at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:274)
	at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:731)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
	at grails.boot.GrailsApp.run(GrailsApp.groovy:99)
	at grails.boot.GrailsApp.run(GrailsApp.groovy:458)
	at grails.boot.GrailsApp.run(GrailsApp.groovy:445)
	at grails.boot.GrailsApp$run.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
	at holder.Application.main(Application.groovy:17)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)

xpusostomos avatar Jul 18 '24 09:07 xpusostomos

Hi, where is the org.grails.plugins.asyncmail.AsyncMailJob coming from? At first I thought it was from https://github.com/gpc/grails-asynchrounous-mail, but there it's named grails.plugin.asyncmail.AsynchronousMailJob.

What versions are you using of Java, Groovy, Grails and relevant plugins and libraries?

matrei avatar Jul 18 '24 11:07 matrei

I have my own version of asyncmail, since it was unmaintained for a long time. So yes, it's basically that plugin you mention, with not much differences, I just renamed everything in there "async" since it was inconsistent. I'm using java 17 (I've tried a number of versions), grails 5.3.6, groovy 3.0.18... I'm not sure what other versions you want to know. Oh, it's quartz scheduler 2.3.2 and grails quartz plugin 2.0.13.

xpusostomos avatar Jul 19 '24 03:07 xpusostomos

I would start by setting a breakpoint on line 59 in AsyncMailGrailsPlugin.groovy to see what the value of the config value sendInterval is.

matrei avatar Jul 19 '24 04:07 matrei

Hmm, so one problem I had was that I had the build setup to use the plugin installation directly, rather than installing it ( implementation project(":org.grails.plugins.asyncmail") ), and despite that it seemed like... oddly... it might be picking up something old in ~/.m2.... having deleted that and run again, asynchronous.mail.send.repeat.interval is null. Apparently the defaults are supposed to be picked up from asyncmail/grails-app/conf/Plugin.groovy .... I don't know what runs that, or how the values setup there make their way into the config object's getProperty routine, but apparently it doesn't happen on Windows for some reason.

xpusostomos avatar Jul 19 '24 12:07 xpusostomos