No unique bean of type [com.atlassian.jira.security.JiraAuthenticationContext]{

Wouter Van Vlaenderen January 18, 2016

I am trying to get the hang of OSGi. Had it working before but suddenly the following stacktrace shows up. I have jira-core added as a dependency in my pom.xml and my constructor looks like this. What could be the problem causing this? Running atlas-clean didn't help.

 

Please let me know if you need any other details.

@Inject
public ManualTriggerAction(@ComponentImport JiraAuthenticationContext jiraAuthenticationContext,
                           @ComponentImport ApplicationProperties applicationProperties,
                           @ComponentImport GroupManager groupManager,
                           @ComponentImport I18nResolver i18nResolver) {
    this.jiraAuthenticationContext = jiraAuthenticationContext;
    this.applicationProperties = applicationProperties;
    this.groupManager = groupManager;
    this.i18nResolver = i18nResolver;
}
NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.jira.security.JiraAuthenticationContext] is defined: Unsatisfied dependency of type [interface com.atlassian.jira.security.JiraAuthenticationContext]: expected at least 1 matching bean

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 18, 2016

I don't see anything obviously wrong from what you've done except that you said you added a jira-core dependency, which you should not need.  The jira-api dependency should be good enough for this.

Are you using the Atlassian Spring Scanner to get your dependencies?  If so then you might need to use @Scanned to get its attention.  There seems to be a pull request in flight that would remove that requirement.

Wouter Van Vlaenderen January 19, 2016

@Chris Fuller the @Scanned annotation is in place, this is not solving my problem. The jira-api dependency is included as well. Please check my class definition,

...
import com.atlassian.jira.security.JiraAuthenticationContext;
import com.atlassian.jira.security.groups.GroupManager;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.web.action.JiraWebActionSupport;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.sal.api.message.I18nResolver;
import javax.inject.Inject;

@Scanned
public class ManualTriggerAction extends JiraWebActionSupport {...}
crf
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 19, 2016

Hrmm, very strange.

I would suggest one of the following strategies:

  • Expand the plugin into a directory and take a look at the housekeeping files that were created for it in META-INF, like MANIFEST.MF and plugin-components/imports to confirm whether or not it has the right information in there.
  • Compare what you have to one of the open-source working examples and see if you can find a difference there.
  • Bisect your source control history to find when it broke and try reverting those changes.

Without access to the actual source or plugin jar, it's hard to guess what the reason for this would be.

0 votes
Steve Kling July 18, 2016

Coming in late on this but you should not modify the spring scanner.xml for this service.

Use the static ComponentAccessor method:

JiraAuthenticationContext jac = ComponentAccessor.getJiraAuthenticationContext()
0 votes
Wouter Van Vlaenderen January 24, 2016

I fixed this by adding the following to src/main/resources/META-INF/spring/scanner.xml. Strange that without this file, the problem was only occurring in classes extending the JiraWebActionSupport (in my case). It would be nice if anyone could clarify this a bit more. Why is this file exactly needed and what is its function?

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
        http://www.atlassian.com/schema/atlassian-scanner
        http://www.atlassian.com/schema/atlassian-scanner/atlassian-scanner.xsd">
    <atlassian-scanner:scan-indexes/>
</beans>

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events