Asynchronous Mail on Grails 2.5.1

299 views
Skip to first unread message

Sheldon du Trevou

unread,
Aug 13, 2015, 8:54:11 AM8/13/15
to Grails Dev Discuss
Asynchronous Mail was working well on Grails 2.4.3 and since we have upgraded to Grails 2.5.1 Asynchronous Mail keeps giving an error when trying to send :

Message: Cannot cast object 'grails.plugin.asyncmail.AsynchronousMailMessage(id:206, to:[te...@temp.com], subject:Registration Activation, status:CREATED)' with class 'grails.plugin.asyncmail.AsynchronousMailMessage' to class 'org.springframework.mail.MailMessage'

Any ideas would be much appreciated. 

Colin Harrington

unread,
Aug 13, 2015, 3:17:04 PM8/13/15
to grails-de...@googlegroups.com
AsynchronusMailMessage isn't a MailMessage


Can you share the stacktrace or what is attempting to cast the AsynchronusMailMessage to a MailMessage?

~ Colin

Colin Harrington
colin.ha...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/6a6112e1-e830-4e42-8f62-b746fa0fe548%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sheldon du Trevou

unread,
Aug 14, 2015, 2:04:35 AM8/14/15
to Grails Dev Discuss
Full Stack Trace :

2015-08-14 08:00:37,591 [ForkJoinPool-5-worker-1] ERROR asyncmail.AsynchronousMailProcessService  - Abort mail sent.
Message: Cannot cast object 'grails.plugin.asyncmail.AsynchronousMailMessage(id:329, to:[te...@temp.com], subject:Registration Activation, status:CREATED)' with class 'grails.plugin.asyncmail.AsynchronousMailMessage' to class 'org.springframework.mail.MailMessage'
   Line | Method
->>  12 | send                in grails.plugin.asyncmail.AsynchronousMailSendService
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    45 | invoke              in com.linkedin.grails.profiler.ProfilerMethodInterceptor
|    73 | processEmailMessage in grails.plugin.asyncmail.AsynchronousMailProcessService
|    30 | doCall              in grails.plugin.asyncmail.AsynchronousMailProcessService$_findAndSendEmails_closure1$_closure2
|   192 | doCall . . . . . .  in groovyx.gpars.pa.GParsPoolUtilHelper$_eachParallelPA_closure8
|   640 | leafApply           in groovyx.gpars.extra166y.AbstractParallelAnyArray$OUPap
|   147 | atLeaf . . . . . .  in groovyx.gpars.extra166y.PAS$FJOApply
|   108 | compute             in groovyx.gpars.extra166y.PAS$FJBase
|   148 | exec . . . . . . .  in jsr166y.RecursiveAction
|   305 | doExec              in jsr166y.ForkJoinTask
|   575 | execTask . . . . .  in jsr166y.ForkJoinWorkerThread
|   755 | scan                in jsr166y.ForkJoinPool
|   617 | work . . . . . . .  in     ''
^   369 | run                 in jsr166y.ForkJoinWorkerThread

Function that is failing that used to work :

MailMessage send(AsynchronousMailMessage message) {
return nonAsynchronousMailService.sendMail {

if (message.attachments) {
multipart true
}
if(message.to && !message.to.isEmpty()){
to message.to
}
subject message.subject
if (message.headers && !message.headers.isEmpty() && isMimeCapable()) {
headers message.headers
}
if (message.html && isMimeCapable()) {
html message.text
} else {
body message.text
}
if (message.bcc && !message.bcc.isEmpty()) {
bcc message.bcc
}
if (message.cc && !message.cc.isEmpty()) {
cc message.cc
}
if (message.replyTo) {
replyTo message.replyTo
}
if (message.from) {
from message.from
}
if(message.envelopeFrom){
envelopeFrom message.envelopeFrom
}
if (isMimeCapable()) {
message.attachments.each {AsynchronousMailAttachment attachment ->
if (!attachment.inline) {
attachBytes attachment.attachmentName, attachment.mimeType, attachment.content
} else {
inline attachment.attachmentName, attachment.mimeType, attachment.content
}
}
}
}
}

Sheldon du Trevou

unread,
Aug 19, 2015, 2:43:17 AM8/19/15
to Grails Dev Discuss
Please could somebody help out here I really need to get this working or need to implement an alternative as this is a long term project that needs to go live in a month and would prefer to use Grails 2.5.1.

Thanks in advance.

Tom Crossland

unread,
Aug 20, 2015, 4:17:27 AM8/20/15
to Grails Dev Discuss
I'm using asynchronous-mail-1.2 (with mail-1.0.7) with Grails 2.5.1, works fine for me.

Raviteja Lokineni

unread,
Aug 20, 2015, 11:13:31 AM8/20/15
to grails-de...@googlegroups.com
The problem seems to be with the return type.

MailMessage send(AsynchronousMailMessage message).

Looks like it should have been AsynchronousMailMessage instead of MailMessage.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grails-dev-disc...@googlegroups.com.
To post to this group, send email to grails-de...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Ravi Teja Lokineni | Application Developer
ServiceNow | Transform IT


Colin Harrington

unread,
Aug 20, 2015, 11:48:11 AM8/20/15
to grails-de...@googlegroups.com
Raviteja,

The code he pasted was from the asynchronous-mail plugin: 
He would have to fork the plugin or override that service to re implement that functionality.

Sheldon, 

What version of asynchronus-mail are you using? 

Have you guys overridden the nonAsynchronousMailService bean? The plugin defines that bean as a grails.plugin.mail.MailService.

The MailService should return a MailMessage.  

If you can reproduce this locally, then try to debug and see what the actual bean is, and what is returning the AsynchronousMailMessage instead of a MailMessage.

If you can boil this down to a reproducible example that would be helpful.

~ Colin





Colin Harrington
colin.ha...@gmail.com

Sheldon du Trevou

unread,
Aug 24, 2015, 9:56:35 AM8/24/15
to Grails Dev Discuss
For anybody else having this issue I changed the option in the config file to false from true :
asynchronous.mail.override=false

Once I made it false it worked because it was not overriding the standard mailService.

On Thursday, August 13, 2015 at 2:54:11 PM UTC+2, Sheldon du Trevou wrote:
Reply all
Reply to author
Forward
0 new messages