NoSuchBeanDefinitionException - Jira upgrade plugin

One of the Jira plugins in version 7.6.4, migrating into Jira version 8.1.2. When I try to do I have done below main changes,

•Updated jira and amps version in pom.xml.
•In atlassian-plugin.xml replaced and with @component and @componentImport respectively.
•Added plugin-config.xml under /src/main/resources/META-INF/spring/ plugin -config.xml

Once I resolved all errors and when I try to run I am getting below exception during runtime.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com.rc.alm.issues.bulkcopy.webwork.BulkCopyAction’: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atlassian.jira.issue.search.managers.IssueSearcherManager’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}

In BulkCopyAction class constructor I am injecting IssueSearcherManager. Even though we don’t have an entry in atlassian-plugin.xml I got that exception so I tried injecting with @componentImport annotation. But it didn’t resolve the issue.

Any suggestions to sort this issue?

Can you share your code of the class file. I just need everything above constructor(including constructor).

Hi Saurabh,

Below is my snippet ,

import static com.google.common.base.Preconditions.checkNotNull;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import com.atlassian.crowd.util.I18nHelper;
import com.atlassian.jira.bc.ServiceOutcome;
import com.atlassian.jira.bc.issue.search.SearchService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.properties.APKeys;
import com.atlassian.jira.issue.search.SearchException;
import com.atlassian.jira.issue.search.SearchRequest;
import com.atlassian.jira.issue.search.managers.IssueSearcherManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.web.action.issue.SearchDescriptionEnabledAction;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;

public class BulkCopyAction extends SearchDescriptionEnabledAction {

private static final Logger LOG = Logger.getLogger(BulkCopyAction.class);
private final SearchService searchService;
private final ConfigService configService;
private final ProjectManager projectMgr;
private final I18nHelper i18nHelper;
private static final long serialVersionUID = 1L;
private static final String ISSUES_URL = “/issues/?jql=”;
private String jql;
private long issueCount;
private String searchUrl;
private String uuid;
private String defaultConfigId;
private Collection projects = new ArrayList();
private Map<String, String> configurations = new HashMap<>();
final String jiraHomePath = ComponentAccessor.getApplicationProperties()
.getString(APKeys.JIRA_BASEURL);

@Autowired
public BulkCopyAction(
@ComponentImport final IssueSearcherManager issueSearcherManager,
final SearchService searchService,
final ProjectManager projectMgr,
final I18nHelper i18nHelper) {
super(issueSearcherManager, searchService);
this.searchService = checkNotNull(searchService);
this.projectMgr = checkNotNull(projectMgr);
this.i18nHelper = checkNotNull(i18nHelper);
}

let me know if I can try any suggestions.

Your constructor should be like

@Autowired
public BulkCopyAction(
@ComponentImport final IssueSearcherManager issueSearcherManager,
@ComponentImport SearchService searchService,
@ComponentImport ProjectManager projectMgr,
@ComponentImport I18nHelper i18nHelper) {
super(issueSearcherManager, searchService);
this.searchService = searchService;
this.projectMgr = projectMgr
this.i18nHelper = i18nHelper;
}

Any manager, service used in your code provided by Atlassian needs @ComponentImport for it to work. Do the same for rest of the classes. If you get unsatisfied dependency error again then it means something wrong with @ComponentImport/@Autowired etc. For any new packaging, always use clean before it. As your current build is throwing unsatisfied dependency.

1 Like