JIRA 7.X groovy error

I am trying to build a query:

Fetch all the fix versions of a ticket, see if that fix version is assigned to any other tickets in the same project.  Below script works fine for 6.X but it is throwing the below error in 7.X

Please help me to fix these errors.

[Static type checking] - Cannot find matching method com.atlassian.jira.ComponentManager#getSearchService(). Please check if the declared type is right and if the method exists.
@ line 61, column 47.
[Static type checking] - Cannot assign value of type com.atlassian.jira.user.ApplicationUser to variable of type com.atlassian.crowd.embedded.api.User
@ line 65, column 18.
[Static type checking] - Cannot find matching method com.atlassian.jira.bc.issue.search.SearchService#search(com.atlassian.crowd.embedded.api.User, com.atlassian.query.Query, com.atlassian.jira.web.bean.PagerFilter). Please check if the declared type is right and if the method exists.
Possible solutions: each(groovy.lang.Closure) @ line 66, column 16.


Issue curissue = issue
curissuekey = curissue.getKey();
Collection<Version> fixVersionList = issue.getFixVersions();
if (fixVersionList.size() > 0)
    for (Version v : fixVersionList)
                fvname = v.getName();
                JqlQueryBuilder builder = JqlQueryBuilder.newBuilder();
                Query query = builder.buildQuery();
                SearchService searchService = ComponentManager.getInstance().getSearchService();
                SearchResults results = null;
                                        User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
                                        results = searchService.search(user, query, PagerFilter.getUnlimitedFilter());
                catch (Exception e){}
                nCount = results.getTotal();

1 answer

1 accepted

It seems that your issue is related of using the ComponentManager as your SearchService and that's deprecated in favor of the ComponentAccessor class.


The problem is here:

SearchService searchService = ComponentManager.getInstance().getSearchService();

Try changing it to this instead:

SearchService searchService = ComponentAccessor.getComponentOfType(SearchService.class);



Then there's another issue where you're trying to get the Current Logged in User and for that you'll need to import the ApplicationUser class as it changed as of Jira 7.x to use that instead of the atlassian.crowd class so simply add the following line on top of your code:

import com.atlassian.jira.user.ApplicationUser

Then change this code:

User user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

To this one:

JiraAuthenticationContext authContext = ComponentAccessor.getJiraAuthenticationContext()
ApplicationUser user = authContext.getLoggedInUser()

Hi Pinchus,

Thanks it worked like charm in JIRA 7.x.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


270 views 0 7
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