Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Problem with JiraAuthenticationContext.getLoggedInUser()

In ScriptRunner, I am using the line 

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getUser()

which works just fine, but is flagged as deprecated. When I use the suggested replacement

def currentUser = JiraAuthenticationContext.getLoggedInUser()

the code is no longer flagged so it should work. However when actually executing the code, I get a strange error message:

2016-06-14 08:44:28,651 ERROR [workflow.ScriptWorkflowFunction]: *************************************************************************************
2016-06-14 08:44:28,651 ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: DM-4391, actionId: 1, file: <inline script>
groovy.lang.MissingMethodException: No signature of method: static is applicable for argument types: () values: []

The JIRA version is 7.1.2, the ScriptRunner version is 4.3.1 (latest). The function JiraAuthenticationContext.getLoggedInUser() belongs to the JIRA 7 API so it should be available to ScriptRunner. Also all interfaces are included:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.UpdateIssueRequest
import com.atlassian.jira.event.type.EventDispatchOption

def currentUser = JiraAuthenticationContext.getLoggedInUser()

I have no idea why this line fails. Please advise.

1 answer

1 accepted

0 votes
Answer accepted

Are you trying ,

ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() ?? 

JiraAuthenticationContext.getLoggedInUser()  ??

I was using the latter, but I now see the error.... for some reason I thought it was a static function, but it is actually not.

I am now using ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()  which works.

Thanks a lot.

I am still confused why the ScriptRunner did not flag the original code as illegal though.

It seems to not be checking whether methods are called statically. But:

> the code is no longer flagged so it should work

this is a wrong inference. It just means (or it should mean) that the methods/properties exist and are of the correct type.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

🤺 Atlympic Event: Partnerships

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

147 views 2 6
Read article

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