grails / grails-mail

The Grails Mail Plugin
https://grails.github.io/grails-mail/
Apache License 2.0
15 stars 25 forks source link

Exception sending mail grails 3.1.4 rest-profile #17

Closed jkolobok closed 5 years ago

jkolobok commented 8 years ago
     mailService.sendMail {
            async true
            to user.email
            from brand.fromEmail
            subject "Your new password"
            html view: "/emails/new-password", model: [firstName: user.firstName, password: newPassword]
        }
Caused by: java.lang.NullPointerException: null
    at grails.plugins.mail.MailMessageContentRenderer.createTemplate(MailMessageContentRenderer.groovy:86)
    at grails.plugins.mail.MailMessageContentRenderer$_render_closure1.doCall(MailMessageContentRenderer.groovy:58)
    at grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:174)
    at grails.plugins.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:57)
    at grails.plugins.mail.MailMessageBuilder.doRender(MailMessageBuilder.groovy:276)
    at grails.plugins.mail.MailMessageBuilder.html(MailMessageBuilder.groovy:294)
    at itracker.MailNotificationService$_sendMailWithNewPassword_closure1.doCall(MailNotificationService.groovy:23)
    at grails.plugins.mail.MailService.sendMail(MailService.groovy:51)
    at grails.plugins.mail.MailService.sendMail(MailService.groovy:57)
    at itracker.MailNotificationService.sendMailWithNewPassword(MailNotificationService.groovy:18)
    at itracker.controllers.UserController.$tt__doResetPassword(UserController.groovy:85)
    at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
    at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
    at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
    at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
    ... 11 common frames omitted
graemerocher commented 8 years ago

Looks like it has a dependency on GSP, so you would have to add the GSP plugin

 compile 'org.grails:grails-plugin-gsp'
AlexKovynev commented 8 years ago

Maybe this is it?:

https://github.com/grails3-plugins/mail/issues/14

jkolobok commented 8 years ago

Nope. #14 is not it. Adding compile 'org.grails:grails-plugin-gsp' helped.

AlexKovynev commented 8 years ago

It's a pity:)

shresthaankit7 commented 6 years ago

Hello, I face the same NullPointException issue. And after adding compile 'org.grails:grails-plugin-gsp' plugin, I faced another issue of : Could not locate email view /email/JobFail in plugin [grails-plugin-gsp]

The view is in grails-app/view/email/JobFail and I'm using service as:

mailService.sendMail {
                to myRecepiants@gmail.com
                from myEmail@gmail.com
                subject mySubject
                html view:"/email/JobFail",model:[params:params],plugin:'grails-plugin-gsp'
            }

The issue doesn't occure when running through intellij but I face this issue if I deploy the war in tomcat.

erichelgeson commented 5 years ago

@shresthaankit7 remove the plugin: