grails / grails-mail

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

Grails 4.0.3: <g:applyLayout>: Unable to resolve view #43

Closed davidkron closed 4 years ago

davidkron commented 4 years ago

Hello

I am upgrading an existing Grails application to version 4.0.3 and get the following error message, which didn't happen with Grails 3.x:

org.grails.taglib.GrailsTagException: [views/mail/test.gsp:12] Error executing tag : Unable to resolve view

Also the error only happens when sending emails from BootStrap (see my example code). When I call the example code from a controller, it works as expected.

/grails-app/init/myapp/BootStrap.groovy

class BootStrap {

    TestService testService

    def init = { servletContext ->
        testService.doSomething()
    }

    def destroy = {
    }
}

/grails-app/services/myapp/TestService.groovy

class TestService {

    void doSomething() {
        sendMail {
            to 'test@example.com'
            from "test@example.com"
            subject "Test"
            html view: '/mail/test', model: [:]
        }
    }
}

/grails-app/views/layouts/mail.gsp

<html>
<head>
    <g:layoutHead/>
</head>
<body>
    <p>/layouts/mail.gsp</p>
    <g:layoutBody/>
</body>
</html>

/grails-app/views/mail/test.gsp

<g:applyLayout name="mail">
    <html>
    <head>
        <title>Test</title>
        <meta name="layout" content="mail" />
    </head>
    <body>
        <p>/mail/test.gsp</p>
        Hello World!
    </body>
    </html>
</g:applyLayout>
davidkron commented 4 years ago

I'm closing this issue. After some debugging I found the problem not to be the mail plugin itself. The same error can also be reproduced with the GroovyPageRenderer.

see: https://github.com/grails/grails-gsp/issues/53