rlovtangen / grails-wkhtmltopdf

9 stars 13 forks source link

Cannot invoke method getBean() on null object when gsp contains g:select #12

Open danpolites opened 9 years ago

danpolites commented 9 years ago

PDF rendering is failing when the GSP contains a g:select tag. I'm able to use other grails tags along with my own tags. I am using grails 2.4.4 (also tried 2.4.5) and version 0.1.10 of the plugin. Looks like it may be an issue with the mail plugin that's doing the rendering.

Here is the error I see:

Cannot invoke method getBean() on null object. Stacktrace follows:
java.lang.NullPointerException: Cannot invoke method getBean() on null object
    at show_gsp$_run_closure2.doCall(show_gsp:53)
    at show_gsp.run(show_gsp:64)
    at grails.plugin.mail.MailMessageContentRenderer$_render_closure1.doCall(MailMessageContentRenderer.groovy:66)
    at grails.plugin.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:180)
    at grails.plugin.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:63)
    at org.wkhtmltox.WkhtmltoxService.renderMailView(WkhtmltoxService.groovy:67)
    at org.wkhtmltox.WkhtmltoxService.makePdf(WkhtmltoxService.groovy:42)
    at org.wkhtmltox.WkhtmltoxService.makePdf(WkhtmltoxService.groovy:37)
    at MyService.generatePdf(MyService.groovy:2884)
    at MyController.pdf(MyController.groovy:40)
    at grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter.doFilter(GrailsAnonymousAuthenticationFilter.java:53)
    at grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter.doFilter(RequestHolderAuthenticationFilter.java:49)
    at grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter.doFilter(MutableLogoutFilter.java:82)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

Here's the line (913) from the grails 2.4.4 FormTagLib that I suspect the mail plugin is having issues with:

def messageSource = grailsAttributes.getApplicationContext().getBean("messageSource")

Thoughts on a work around?

rlovtangen commented 9 years ago

Are you able to use mail plugin directly with the same markup?