delegator = dctx.getDelegator(); // add to RunAutoNotification.groovy
On Apr 6, 2010, at 7:06 AM, Koon Sang wrote:
Hello,I have created a scheduled job to run at certain time. The job calls myservice 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 thefollowing error:groovy.lang.MissingPropertyException: No such property: delegator for class:RunAutoNotificationorg .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 justwonder 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 webpage. 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.
smime.p7s
Description: S/MIME cryptographic signature
