It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

can't figure out how to debug my scriptrunner script

Esty Heller Jun 17, 2013

I'm trying to write a postfunction script to check the value of a custom field (Assigned Tester). If it's empty, I want to get the reporter of the issue, check if he is part of the Assigned Tester role, and if so, assign him to this custom field.

I'm getting stuck on this error java.lang.ClassCastException: com.atlassian.jira.user.BridgedDirectoryUser cannot be cast to com.atlassian.jira.user.ApplicationUser

I'm new at this, and I can't figure out how to debug... I tried system.out.println, but I don't know where I would see it? I trailed the output log atlassian-jira.log (that's where I see the error message), but I don't see anything that I'm trying to print out.

Here is the part of my code that is having trouble, I appreciate any tips.

ComponentManager componentManager = ComponentManager.getInstance()
CustomField assignedTester = componentManager.getCustomFieldManager().getCustomFieldObjectByName("Assigned Tester")

if (assignedTester.getValue(myIssue) == null){
	//check if the reporter can be a tester
	User myReporter = myIssue.getReporter()
	//User myOldTester = issue.getCustomFieldValue(assignedTester)
	ProjectRoleManager projectRoleManager = ComponentManager.getComponentInstanceOfType(ProjectRoleManager.class) as ProjectRoleManager
	ProjectRole testRole = projectRoleManager.getProjectRole("Assigned Testers")
	if (projectRoleManager.isUserInProjectRole(myReporter, testRole, issue.getProjectObject())){
		//the reporter can be a tester, so assign him
		IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
		assignedTester.updateValue(null, issue, new ModifiedValue(null, myReporter), changeHolder)

6 answers

1 accepted

11 votes
Answer accepted
Henning Tietgens Jun 17, 2013

To get debug messages you can use the object log (org.apache.log4j.Category). It's already binded to your script. So if you write

log.error "Debug message"

you will see this message in the atlassian-jira.log. You could implement different levels of debug messages. log.debug(),, log.warn() and log.error() and set the log level at the beginning of your script.


In this way you can develop with log level debug and after finishing raise the level to error to get only important messages in the log.


Esty Heller Jun 17, 2013

thanks, i can see the messages now

2 votes
JamieA Jun 17, 2013

Take a look at this page:

You will need to convert the user types, or get a new User object from the key of the applicationUser (or something).

Esty Heller Jun 17, 2013

jamie, thanks for the link. still working on this, and after many hours, not getting anywhere.

which user needs to be converted? the reporter needs to be converted to application user to update the custom field value? and how would i do that... thanks

1 vote
David Keane May 29, 2015

You need to look at the server log files where JIRA is running, System.out.print will appear there. I found my logs in catalina.out for example, apache


1 vote
BradA Nov 01, 2016

In the latest version of ScriptRunner, if you're creating a simple script rather than a listener class, it appears you need to initialize the log object yourself:


def log = Logger.getLogger("com.example.script")
0 votes
JamieA Jun 17, 2013

Is this jira 6? Possibly there is a bug in isUserInProjectRole in jira 6.

0 votes
Henning Tietgens Jun 17, 2013

Is there a reason why you use myIssue and issue in your source?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in United States

Unofficial downtown meetup week of June 3 or 4?

Hello everyone!  It's been a while since Houston's had a Atlassian Community Event (formerly Atlassian User Group meeting) so I wanted to gauge interest in an unofficial downtown meetup after wo...

12 views 0 0
View post

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