Hello, I have created a scheduled job to run at certain time. The job calls my service which I define as the followoing:
<service name="AutoNotificationCertificateExpiry" engine="groovy" location="component://order/webapp/ordermgr/order/RunAutoNotification.groovy" invoke=""> <description>Auto-notification Certificate Expiry</description> </service> RunAutoNotification.groovy is as follows (omitting the import): try { AutoNotification notification = new AutoNotification(delegator, dispatcher); notification.notifyUsersOfExpiringCertificate(); return "success" } catch (Exception e) { Debug.logError(e, "error", "RunAutoNotification.groovy"); return "error" } I noticed that during OFBIZ startup, the job is called. However, I got the following error: groovy.lang.MissingPropertyException: No such property: delegator for class: RunAutoNotification org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50) org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getGroovyObjectProperty(ScriptBytecodeAdapter.java:537) RunAutoNotification.run(RunAutoNotification.groovy:7) org.ofbiz.base.util.GroovyUtil.runScriptAtLocation(GroovyUtil.java:117) org.ofbiz.service.engine.GroovyEngine.serviceInvoker(GroovyEngine.java:64) org.ofbiz.service.engine.GroovyEngine.runSync(GroovyEngine.java:52) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:390) org.ofbiz.service.ServiceDispatcher.runSync(ServiceDispatcher.java:219) org.ofbiz.service.GenericDispatcher.runSync(GenericDispatcher.java:159) org.ofbiz.service.job.GenericServiceJob.exec(GenericServiceJob.java:69) org.ofbiz.service.job.JobInvoker.run(JobInvoker.java:241) java.lang.Thread.run(Unknown Source) Looking at the error log, I guess "delegator" cannot be found. I just wonder how I can get a reference of delegator and dispatcher to pass to groovy for scheduled job. The code runs fine if I called it from a web page. Your kind advice is appreciated. Thank you. -- View this message in context: http://n4.nabble.com/Calling-groovy-from-scheduled-job-OFVIZ-9-04-tp1752673p1752673.html Sent from the OFBiz - User mailing list archive at Nabble.com.