Search code examples
springosgijira-plugin

No qualifying bean of type [com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator]


I started to develop a Jira External System Importer Plugin and I should upload a JSON File using its Setup Page but when I add "TemporaryAttachmentsMonitorLocator" to my SetupPage class constructor and I click on my importer's button, it fails with the error: "No qualifying bean of type [com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator]"

[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dev.addax.jira.plugins.trello2jira.web.TrelloSetupPage': Unsatisfied dependency expressed through constructor argument with index 4 of type [com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator]: No qualifying bean of type [com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: **No qualifying bean of type [com.atlassian.jira.issue.TemporaryAttachmentsMonitorLocator] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency**. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=)}
[INFO] [talledLocalContainer]   at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
public class TrelloSetupPage extends AbstractSetupPage {

    private final TemporaryAttachmentsMonitorLocator locator;

    public TrelloSetupPage(@ComponentImport UsageTrackingService usageTrackingService, @ComponentImport WebInterfaceManager webInterfaceManager,
                           @ComponentImport PluginAccessor pluginAccessor, @ComponentImport EventPublisher eventPublisher,
                           @ComponentImport TemporaryAttachmentsMonitorLocator locator) {
        super(usageTrackingService, webInterfaceManager, pluginAccessor, eventPublisher);
        this.locator = locator;
    }
    // ... other content omitted.
}

The other params in my constructor are resolved right. Only this one is what it fails. If I remove that class I can navigate to my SetupPage as is expected.

Finally, the class is exported by the OSGi system bundle and I checked it is even still used as a service by the Jira native JIM Plugin.

Any idea what might be the reason why it is not finding this class?


Solution

  • I removed @ComponentImport TemporaryAttachmentsMonitorLocator locator and I included ComponentAccessor.getOSGiComponentInstanceOfType(TemporaryAttachmentsMonitorLocator.class) in the constructor body. I don't know why @ComponentImport does not work for this case but the workaround works like a charm.