在战争模式下,Grails Mail服务不与guartz调度程序一起工作 [英] Grails Mail service not working with guartz scheduler in war mode

查看:96
本文介绍了在战争模式下,Grails Mail服务不与guartz调度程序一起工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 静态触发器= {
cron名称: 'DashboardReporting',cronExpression:0 0 11,20 * *?





$ b

现在在执行过程中,我使用grails异步插件发送邮件, -app模式:

  emailNotificationService.sendDashboardReportEmail(emaiListing,[model:model,XYZmodel:XYZmodel])
code>

现在当我为开发目的运行应用程序并从本地机器发送邮件时,



但是,当我使用run-war运行相同的代码时,我得到以下异常:

  java.lang.NullPointerException在java.net.URI处
$ parser.parse(URI.java:3042)$ b $在java.net.URI。< init>(URI.java :588)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance (DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77 )
在org.codehaus.groovy.runtime.callsite.ConstructorSite $ ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java :57)$ or $ $ b $ org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCon结构体(AbstractCallSite.java:182)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
在grails.plugin.mail.MailMessageContentRenderer $ PageRenderRequestCreator.createInstance( MailMessageContentRenderer.groovy:198)
at grails.plugin.mail.MailMessageContentRenderer $ PageRenderRequestCreator $ createInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java :45)
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java :124)
at grails.plugin.mail.MailMessageContentRenderer $ RenderEnvironment.init(MailMessageContentRenderer.groovy:147)
at grails.plugin.mail.MailMessageContentRenderer $ RenderEnvironment.this $ 2 $ init(MailMessageContentRenderer.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.Native MethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java: 68)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
。在grails.plugin.mail.MailMessageContentRenderer $ RenderEnvironment.with(MailMessageContentRenderer.groovy 108)
:178)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:483)
在org.codehaus.groovy.reflection。 CachedMethod.invoke(CachedMethod.java:90)维持在org.codehaus.groovy.runtime org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite $ StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)

。 callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
在org.codehaus.groovy.runtime。 callsite.AbstractCallSite.call(AbstractCallSite.java:108)
处grails.plugin.mail.MailMessageContentRenderer org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
。 render(MailMessageContentRenderer.groovy:63)
at grails.plugin.mail.MailMessageContentRenderer $ render.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.default Call(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.doRender(AsynchronousMailMessageBuilder。常规:在sun.reflect.NativeMethodAccessorImpl.invoke0 281)
(本机方法)维持在sun.reflect.DelegatingMethodAccessorImpl sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

。调用(DelegatingMethodAccessorImpl.java:43)
在java.lang.reflect.Method.invoke(Method.java:483)
在org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoCachedMethodSiteNoUnwrapNoCoerce.invoke( PogoMetaMethodSite.java:207)美元,org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56 b $ b)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent( CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.cod ehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
在grails.plugin.asyncmail.AsynchronousMailMessageBuilder.html(AsynchronousMailMessageBuilder.groovy:267)在sun.reflect.NativeMethodAccessorImpl
。在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)处
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)处
在java处
。 lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke( MetaMethod.java:324)在groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207
)在groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110

。在常规.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1119)
at groovy.lang.ExpandoMetaClass.invokeMethod(Expand oMetaClass.java:1110)
在groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
在org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)

在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.deerwalk.om.EmailNotificationService $ _sendMultipleMail_closure3.doCall(EmailNotificationService.groovy:32)
at com.deerwalk.om.EmailNotificationService $ _sendMultipleMail_closure3.doCall(EmailNotificationService.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl。 java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang。 reflect.Method.invoke(Method.java:483)维持在org.codehaus.groovy org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)

。 runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
处org.codehaus.groovy org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
。 runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
在grails.plugin.asyncmail。 AsynchronousMailService.sendAsynchronousMail(AsynchronousMailService.groovy:21)
at grails.plugin.asyncmail.AsynchronousMailService $$ FastClassBySpringCGLIB $$ a38fa914.invoke(< generated>)
at org.springframework.cglib.proxy.MethodProxy .invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy $ CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.spring framework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor $ 1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction .interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
在org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
在org.springframework.aop.framework.ReflectiveMethodInvocation .proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at grails.plugin.asyncmail.AsynchronousMailService $$ EnhancerBySpringCGLIB $ $ 3608bbae.sendAsynchronousMail(<生成>)
在grails.plugin.asyncmail.AsynchronousMailService $ sendAsynchronousMail.call(未知来源)
在org.codehaus.groovy.runtime.callsite.CallSiteArray.default在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
处(org.codehaus.groovy.runtime.callsite.AbstractCallSite)调用(CallSiteArray.java:45)
。在AsynchronousMailGrailsPlugin $ _configureSendMail_closure9.doCall(AsynchronousMailGrailsPlugin.groovy:132)上
(org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:82)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl。 java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
。在org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
在org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite $ PogoMetaMethodSiteNoUnwrap NoCoerce.invoke(PogoMetaMethodSite.java:248)
处org.codehaus.groovy.runtime.callsite org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
。 CallSiteArray.defaultCall(CallSiteArray.java:45)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
在org.codehaus.groovy.runtime.callsite。 AbstractCallSite.call(AbstractCallSite.java:116)
。在com.deerwalk.om.EmailNotificationService.sendMultipleMail(EmailNotificationService.groovy:29)
。在com.deerwalk.om.EmailNotificationService.this $ 2 $ sendMultipleMail(EmailNotificationService .groovy作为)
在com.deerwalk.om.EmailNotificationService $在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java这个$ 2 $ sendMultipleMail $ 0.callCurrent(来源不明)
: 49)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
在org.codehaus.groovy.runtime.callsite.AbstractCallSite.c allCurrent(AbstractCallSite.java:153)
at com.deerwalk.om.EmailNotificationService.sendDashboardReportEmail(EmailNotificationService.groovy:51)
at com.deerwalk.om.EmailNotificationService $$ FastClassBySpringCGLIB $$ c42786d4.invoke( <在org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
。在org.springframework.aop.framework.CglibAopProxy $ CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java)
;产生> :708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor $ 1.proceedWithInvocation(TransactionInterceptor.java:98)在org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)

在org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
在org.springframework.aop.framework.Reflect iveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.deerwalk.om.EmailNotificationService $$ EnhancerBySpringCGLIB $$ c078a16e.sendDashboardReportEmail(小于生成>)
。在com.deerwalk.om.EmailNotificationService $ sendDashboardReportEmail.call(未知来源)
。在org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall( CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call( AbstractCallSite.java:120)
在com.deerwalk.om.DashboarReportingJob.execute(DashboarReportingJob.groovy:35)
处太阳sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)
。 reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces在Grails.plugins.quartz.GrailsJobFactory $ GrailsJob.execute(GrailsJobFactory.java:104)上
$ java.util.imlect.Method.invoke(Method.java:483)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool $ WorkerThread.run(SimpleThreadPool.java:573)

我使用了async提供的默认石英版本。另外值得注意的是,我并不直接注入异步邮件服务,所以我使用以下方式自动装配:

  @Autowired 
AsynchronousMailService asyncMailService

但是这件事情在run-app和其他许多用法服务,只有在战争模式下这个错误表面。



我也尝试了普通的邮件插件,但也遇到同样的问题。任何建议家伙??

解决方案

我知道这个问题已经有点老,但提供的答案不适用于我grails 3.0.9。具体来说,它需要我设置一个全局serverUrl,它覆盖任何开发/测试/生产环境中指定的任何内容。



以下内容添加到BootStrap.groovy诀窍。看起来,Grails中的LinkGenerator初始化实际上是罪魁祸首,而不是邮件插件。

  LinkGenerator grailsLinkGenerator = grailsApplication.mainContext。的getBean( grailsLinkGenerator)
grailsLinkGenerator.configuredServerBaseURL =
grailsLinkGenerator.configuredServerBaseURL:
grailsApplication.config.grails.serverUrl


I send a mail at a specific time using quartz scheduler :

static triggers = {
   cron name: 'DashboardReporting', cronExpression:"0 0 11,20 * * ?"
}

Now inside execute I send the mail using grails async plugin which works perfectly under run-app mode:

emailNotificationService.sendDashboardReportEmail(emaiListing, [model:model,XYZmodel:XYZmodel])

Now this thing works perfectly when I do run-app for development purposes and sends mail from my local machine.

But when I run the same code using run-war I get this exception :

java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3042)
at java.net.URI.<init>(URI.java:588)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
at grails.plugin.mail.MailMessageContentRenderer$PageRenderRequestCreator.createInstance(MailMessageContentRenderer.groovy:198)
at grails.plugin.mail.MailMessageContentRenderer$PageRenderRequestCreator$createInstance.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.init(MailMessageContentRenderer.groovy:147)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.this$2$init(MailMessageContentRenderer.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:178)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite$StaticMetaMethodSiteNoUnwrapNoCoerce.invoke(StaticMetaMethodSite.java:148)
at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at grails.plugin.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63)
at grails.plugin.mail.MailMessageContentRenderer$render.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.doRender(AsynchronousMailMessageBuilder.groovy:281)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:56)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.html(AsynchronousMailMessageBuilder.groovy:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1207)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1119)
at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1016)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
at com.deerwalk.om.EmailNotificationService$_sendMultipleMail_closure3.doCall(EmailNotificationService.groovy:32)
at com.deerwalk.om.EmailNotificationService$_sendMultipleMail_closure3.doCall(EmailNotificationService.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:207)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
at grails.plugin.asyncmail.AsynchronousMailService.sendAsynchronousMail(AsynchronousMailService.groovy:21)
at grails.plugin.asyncmail.AsynchronousMailService$$FastClassBySpringCGLIB$$a38fa914.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at grails.plugin.asyncmail.AsynchronousMailService$$EnhancerBySpringCGLIB$$3608bbae.sendAsynchronousMail(<generated>)
at grails.plugin.asyncmail.AsynchronousMailService$sendAsynchronousMail.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callSafe(AbstractCallSite.java:82)
at AsynchronousMailGrailsPlugin$_configureSendMail_closure9.doCall(AsynchronousMailGrailsPlugin.groovy:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:248)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:68)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at com.deerwalk.om.EmailNotificationService.sendMultipleMail(EmailNotificationService.groovy:29)
at com.deerwalk.om.EmailNotificationService.this$2$sendMultipleMail(EmailNotificationService.groovy)
at com.deerwalk.om.EmailNotificationService$this$2$sendMultipleMail$0.callCurrent(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:153)
at com.deerwalk.om.EmailNotificationService.sendDashboardReportEmail(EmailNotificationService.groovy:51)
at com.deerwalk.om.EmailNotificationService$$FastClassBySpringCGLIB$$c42786d4.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.deerwalk.om.EmailNotificationService$$EnhancerBySpringCGLIB$$c078a16e.sendDashboardReportEmail(<generated>)
at com.deerwalk.om.EmailNotificationService$sendDashboardReportEmail.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at com.deerwalk.om.DashboarReportingJob.execute(DashboarReportingJob.groovy:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:104)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)

I have used the default quartz version provided by the async. Also a thing of note is I cound not directly inject the async mail service so I autowired it with :

 @Autowired
AsynchronousMailService asyncMailService

But again this thing is working fine with run-app and under other many usage of the service, only in war mode this error surfaces.

I also tried the normal mail plugin but had the same problem. Any suggestions guys ??

解决方案

I know this question is already a bit older, but the answer provided does not work for me in grails 3.0.9. Specifically, it would require me to set a global serverUrl that overrides anything specified for any of the development/testing/production environments.

The below, added to BootStrap.groovy does the trick. It seems that the LinkGenerator initialization in grails is actually the culprit, rather than the mail plugin.

LinkGenerator grailsLinkGenerator = grailsApplication.mainContext.getBean("grailsLinkGenerator")
grailsLinkGenerator.configuredServerBaseURL = 
                    grailsLinkGenerator.configuredServerBaseURL ?:
                         grailsApplication.config.grails.serverUrl

这篇关于在战争模式下,Grails Mail服务不与guartz调度程序一起工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆