Sending custom email from Builtin Scripts throws GroovyCastException

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

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.

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?

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?

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

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,639 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you