Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't send Message with view from quartz job (Grails 3.1.3) #14

Closed
AlexKovynev opened this issue Mar 4, 2016 · 7 comments
Closed

Can't send Message with view from quartz job (Grails 3.1.3) #14

AlexKovynev opened this issue Mar 4, 2016 · 7 comments

Comments

@AlexKovynev
Copy link

AlexKovynev commented Mar 4, 2016

With 3.1.0 it's all ok.

ERROR grails.plugins.quartz.listeners.ExceptionPrinterJobListener - Exception occurred in job: Grails Job
org.quartz.JobExecutionException: 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: null
        at java.net.URI$Parser.parse(URI.java:3042)
        at java.net.URI.<init>(URI.java:588)
        at grails.plugins.mail.MailMessageContentRenderer$PageRenderRequestCreator.createInstance(MailMessageContentRenderer.groovy:192)
        at grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.init(MailMessageContentRenderer.groovy:141)
        at grails.plugins.mail.MailMessageContentRenderer$RenderEnvironment.with(MailMessageContentRenderer.groovy:172)
        at grails.plugins.mail.MailMessageContentRenderer.render(MailMessageContentRenderer.groovy:57)
        at grails.plugins.mail.MailMessageContentRenderer$render.call(Unknown Source)
        at grails.plugins.mail.MailMessageBuilder.doRender(MailMessageBuilder.groovy:276)
        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:497)
        at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
        at grails.plugins.mail.MailMessageBuilder.html(MailMessageBuilder.groovy:294)
        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:497)
        at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
        at sklad.SendbirthJob$_execute_closure1$_closure3.doCall(SendbirthJob.groovy:28)
@delsner
Copy link

delsner commented Apr 22, 2016

I have the same Problem on Grails 3.1.3! Have you found any workaround yet?

@AlexKovynev
Copy link
Author

AlexKovynev commented Apr 23, 2016

Unfortunately not, the plugin developer does not respond to errors :(
graemerocher save us!:)

@AlexKovynev
Copy link
Author

I find workaround!
Set grails.serverURL in config (for development enviroment too - "http://localhost:8080" )

@alexkramer
Copy link

I had this same issue when sending an email from a JMS listener. I was able to workaround it without needing to set the grails.serverURL. I injected the groovyPageRenderer and rendered the email template myself and passed the string value to the html parameter of the sendMail closure. Below is an example of how I was able to accomplish it with some hand waving (I am obviously missing all of the jms annotations and static methods)

import grails.gsp.PageRenderer

class SomeJmsListenerService {

    def mailService
    PageRenderer groovyPageRenderer

    def onMessage(String jsonMessage) {
        String emailTemplate = groovyPageRenderer.render([view: "/email/_emailTemplate", model: [userName: "Bob"]])
        mailService.sendMail {
            to "bob@somemailserver.com"
            subject "Hello Bob"
            html emailTemplate
        }
    }
}

@sudosandwich3
Copy link

There may still be an issue in war deployments. Looks like it is looking for gsp files under: '/WEB-INF/grails-app/views' when the files are located in '/WEB-INF/classes'

@tkvw
Copy link

tkvw commented May 31, 2017

Created a PR for this: #24

@sbglasius
Copy link

PR #24 was merged. Closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants