Sending custom email from Builtin Scripts throws GroovyCastException

Matt Howell April 23, 2013

I would like to send a custom email from a workflow post function (using Script Runner), but first I have been using the "Builtin Scripts" in JIRA Administration to experiment.

When I preview various email configurations, the condition correctly evaluates to true, and the email is displayed correctly, but when I try to actually run the email, I get a GroovyCastException (details below). This seems to happen no matter what issue and/or settings I provide.

I've searched this site, as well as Google, and haven't come across a solution. Has anyone seen this, and been able to resolve it?

---

JIRA Version: 5.2.4
Script Runner Version: 2.1.3

Email Details:

  • Condition: [issue.priority?.name == 'NA']
  • Email Template: [Hello World]
  • Subject Template: [Hello World]
  • Email Format: [Plain Text]
  • To Addresses: (my email address)
  • Include Attachments: [None]
  • From email address: (empty - shows proper email address in tooltip)
  • Preview Issue Key: [DGS-128] (issue exists, and has priority properly set to NA)

Result:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.jira.event.issue.IssueEvent@6181836a[issue=DGS-128,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][id,16044][author,mhowell][created,2013-04-24 13:01:16.737][issue,12395],eventTypeId=1,sendMail=false,params={},subtasksUpdated=false]' with class 'java.lang.String' to class 'com.atlassian.jira.event.issue.IssueEvent'


Stack Trace:

org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.jira.event.issue.IssueEvent@6181836a[issue=DGS-128,comment=<null>,worklog=<null>,changelog=[GenericEntity:ChangeGroup][id,16044][author,mhowell][created,2013-04-24 13:01:16.737][issue,12395],eventTypeId=1,sendMail=false,params={},subtasksUpdated=false]' with class 'java.lang.String' to class 'com.atlassian.jira.event.issue.IssueEvent'

	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:360)
...

2 answers

0 votes
Srinivas Marripudi June 17, 2013

Hi Matt, by any chance have you added the 'Send Custom Email' script under Installed Listeners (option under Script Listeners) ? If so, remove it and test the workflow post function again.

I got a similar Class cast error for the same script (Jira 4.1 & Script Runner 1.7.13), when testing (previewing) this built in script. I got this error everytime I specified a 'issue' object. But when I refreshed the script (cleared the entries & also removed it as added listener) & tried again with details (simple email text input data as yours!), it worked fine in workflow post function. I hope it helps.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2013

I will look at that but you may not be able to actually run it from there... it's in the built-in scripts in the admin section just for previewing. If everything else works you should copy it to a workflow post-function.

Matt Howell April 23, 2013

I have also put the same configuration into a workflow post function. Although the issue progresses through the workflow correctly, an email never appears to get sent. I also don't see any errors in the catalina.out, or any emails show up in the Mail Queue.

Any suggestions on how to see more details of what might be happening?

Matt Howell April 30, 2013

Quick update: I tried this again today as a post function, and no errors are logged in catalina.out. No email is sent, despite all other system emails working correctly. I am open to any further suggestions of how to triage this further?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 2, 2013

Can you set the log level to debug and look for messages?

Suggest an answer

Log in or Sign up to answer