我们有预定的开票服务,我们将发票发送到客户的电子邮件中。

asynchronousMailService.sendMail {
            multipart true
            to emailTo.split("[,;]")
            bcc bccString
            from fromString
            subject subjectString
            html view:'/email/invoiceEmailTemplate',
                    model: [companyName: companyName, customerFirstName:  order.customer.firstName,
                            xeroInvoiceId: invoice.invoiceNumber, invoiceTotal: order.totalAmount,
                            invoiceUrl: invoiceUrl,
                            currencyCode: invoice.currencyCode, dueDate: invoice.dueDate]
            attachBytes invoice.invoiceNumber+".pdf" , 'application/pdf', invoiceBytes
        }

导致此错误:
2016-03-09 18:22:23,073 [quartzScheduler_Worker-10] ERROR listeners.ExceptionPrinterJobListener  - Exception occurred in job: Grails Job
        org.quartz.JobExecutionException: java.lang.NullPointerException [See nested exception: java.lang.NullPointerException]
                at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:111)
                at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
                at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
        Caused by: java.lang.NullPointerException
                at java.net.URI$Parser.parse(URI.java:3023)
                at java.net.URI.<init>(URI.java:595)
                at grails.plugin.mail.MailMessageContentRenderer$PageRenderRequestCreator.createInstance(MailMessageContentRenderer.groovy:198)
                at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.init(MailMessageContentRenderer.groovy:147)
                at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:178)
                at grails.plugin.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63)
                at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.doRender(AsynchronousMailMessageBuilder.groovy:281)
                at grails.plugin.asyncmail.AsynchronousMailMessageBuilder.html(AsynchronousMailMessageBuilder.groovy:267)
                at com.mycompany.thirdparty.InvoiceService$_emailInvoiceToCustomer_closure5.doCall(InvoiceService.groovy:118)
                at grails.plugin.asyncmail.AsynchronousMailService.sendAsynchronousMail(AsynchronousMailService.groovy:21)
                at AsynchronousMailGrailsPlugin$_configureSendMail_closure9.doCall(AsynchronousMailGrailsPlugin.groovy:132)
                at com.mycompany.thirdparty.InvoiceService.emailInvoiceToCustomer(InvoiceService.groovy:112)
                at com.mycompany.thirdparty.InvoiceService$_createInvoice_closure2.doCall(InvoiceService.groovy:47)
                at grails.plugin.multitenant.core.MultiTenantService$_doWithTenantId_closure1_closure2.doCall(MultiTenantService.groovy:32)
                at grails.plugin.hibernatehijacker.template.HibernateTemplates$_withTransaction_closure1.doCall(HibernateTemplates.groovy:39)
                at grails.plugin.hibernatehijacker.template.HibernateTemplates.withTransaction(HibernateTemplates.groovy:37)
                at grails.plugin.multitenant.core.MultiTenantService$_doWithTenantId_closure1.doCall(MultiTenantService.groovy:31)
                at grails.plugin.hibernatehijacker.template.HibernateTemplates$_withNewSession_closure2.doCall(HibernateTemplates.groovy:65)
                at grails.plugin.hibernatehijacker.template.HibernateTemplates.withNewSession(HibernateTemplates.groovy:57)
                at grails.plugin.multitenant.core.MultiTenantService.doWithTenantId(MultiTenantService.groovy:30)
                at grails.plugin.multitenant.singledb.MtSingleDbPluginSupport$_createWithTenantIdMethod_closure2.doCall(MtSingleDbPluginSupport.groovy:141)
                at com.mycompany.thirdparty.InvoiceService.createInvoice(InvoiceService.groovy:38)
                at com.mycompany.thirdparty.InvoiceJob.execute(InvoiceJob.groovy:13)
                at grails.plugins.quartz.GrailsJobFactory$GrailsJob.execute(GrailsJobFactory.java:102)

上面的错误日志仅在生产服务器中发生,并且无法在本地计算机和开发服务器上进行复制。

有任何想法吗?

最佳答案

我在这里回答了这个问题:Grails Mail service not working with guartz scheduler in war mode

这是AsyncMail无法获取服务器的URL。最简单的事情是通过grails.serverURL config属性对其进行配置。

07-28 07:39