Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Script error: cannot cast object 'user' with class with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'

After migrating to JIRA 7, from JIRA 6.4.3, the send email script listener does not work anymore.

The error in the logs is: 

Script error: cannot cast object 'user' with class with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'

Please let me know if you need any other details.

Thank you.

3 answers

Hi Cristina,

I can't see where you get a user from in the script you provided. Are you sure the error is coming from this post-function and not another one on the same transition?

For JIRA 7 your script should look like:

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()

def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'Process Area' }
def passesCondition = false

if (cf != null) {
    def fieldConfig = issue.getCustomFieldValue(cf)
    if (fieldConfig.toString().contains('System Architecture')) {
        passesCondition = true
    else {
        passesCondition = false



There is indeed no user type object in the script, the problem is that I set an email address. This is a listener that sends emails, and the error is related, I think, to how script Runner calls the method that sends emails. I have a few email addresses configured in the 'to' section' of the listener and the error, I think, is related to that.


Thank you.

Could you include a screenshot of how you have your listener configured? Are you also able to send the message you get in the logs when the listener runs? There may be more to the message which will give us some clues.


Hello @Adam Markham, I added the screenshots of the configuration, and the error message:


2017-02-10 01:33:09,411 http-nio-8080-exec-16 ERROR uidq5816 93x37102x1 1h6f0qr /secure/QuickCreateIssue.jspa [c.o.s.jira.workflow.ScriptWorkflowFunction] Script function failed on issue: SEPG-844, actionId: 1, file: <inline script>
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'uidq5816(uidq5816)' with class 'com.atlassian.jira.user.DelegatingApplicationUser' to class 'com.atlassian.crowd.embedded.api.User'

Hi Cristina,

Thanks for that. I don't see anything wrong with the configuration. I guess process area and system architecture custom fields are not user picker ones?


Hello Adam,

"Process Area" is a custom field, a list select. "System Architecture" is a value inside the "Process Area" custom field.

Basically, what we are trying to do is:

When somebody creates a ticket and selects the value "System Architecture" for the "Process Area" custom field, then an email should be sent to the leaders of that area. 

In JIRA 6.4.3 it used to work. Now we get the error that I added above. 

I hope this is clearer now, please let me know.



Please let me know if you have any updates on this , or if you need additional info.

Thank you.

Hi Cristina,

Are you really sure that the send custom email cause this error ? Do you have any custom post functions or custom listeners ?


Hello @Thanos Batagiannis [Adaptavist],

Yes, going to Script Listeners, we selected: 'Send a custom email', then we added the condition and the template. When trying to create an issue for which we expect an email, we do not get the email, and in the logs we find the error mentioned above.

I attached 3 more screenshots to see that this is the case. email3.pngemail2.pngemail1.png
Thank you.


Sorry for asking the same question twice, but could you please check at Built in Scripts -> Script Registry for other Script Runner Listeners or Post Functions or Validators or Conditions that are not properly updated in order to match the JIRA v7 API. 

I am asking that because if there was a bug in the Send Custom Email Listener something similar to the stack trace below would appear to your logs

2017-02-15 17:27:44,397 http-bio-8080-exec-3 ERROR admin [onresolve.scriptrunner.runner.AbstractScriptListener] *************************************************************************************
2017-02-15 17:27:44,398 http-bio-8080-exec-3 ERROR admin [onresolve.scriptrunner.runner.AbstractScriptListener] Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, script: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail
groovy.lang.MissingPropertyException: No such property: illegalProperty for class: com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.sendMail(SendCustomEmail.groovy:536)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$sendMail$6.callCurrent(Unknown Source)
	at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:558)

Hi @Rafael Franco [Adaptavist],


Here is the script:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.ManagerFactory
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.context.IssueContext
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.fugue.Option
import org.apache.log4j.Category
import com.atlassian.jira.util.JiraUtils;
import org.ofbiz.core.entity.GenericValue;
import com.atlassian.jira.issue.MutableIssue

def componentManager = ComponentManager.instance
def compAccessor = new ComponentAccessor()
def customFieldManager = compAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjects(issue).find { == 'Process Area'}
def passesCondition = false
def fieldConfig = issue.getCustomFieldValue(cf)
if(fieldConfig.toString().contains('System Architecture'))
passesCondition = true
passesCondition = false

@Cristina Abunei can you please reedit your post using the "code" option in the editor otherwise becomes hard to read? Thanks

Hello, I edited the code.

Thank you.

Hi Cristina,

Can you provide us with your current script so we can take a look?



Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

217 views 0 6
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you