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

Could not inject PluginLicenseManager

Felipe Brandão Nascimento April 26, 2016

Hi guys!

I'm trying to inject a PluginLicenseManager on my Macro so i can disable it when the license is invalid, but the autowiring/import is not working.

I followed this tutorial and some other questions, but I always end up with the following exception:

[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.bitbucket.felipebrnd.confluence.jlatexmath.macro.JLatexMathInlineMacro': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.upm.api.license.PluginLicenseManager]: : No qualifying bean of type [com.atlassian.upm.api.license.PluginLicenseManager] 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=pluginLicenseManager)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.upm.api.license.PluginLicenseManager] 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=pluginLicenseManager)

Can you guys help me get this working ?

Tks in advance!


My atlassian-plugin.xml looks like this:

<!-- License manager -->
<component-import key="pluginLicenseManager" interface="com.atlassian.upm.api.license.PluginLicenseManager"/>

I've added the dependecies on pom.xml as follows:

<!-- Atlassian License API -->
<dependency>
     <groupId>com.atlassian.upm</groupId>
     <artifactId>licensing-api</artifactId>
     <version>2.0.1</version>
     <scope>provided</scope>
</dependency>
<dependency>
     <groupId>com.atlassian.upm</groupId>
     <artifactId>upm-api</artifactId>
     <version>2.0.1</version>
     <scope>provided</scope>
</dependency>

And my Macro class looks like this:

public class MyBlockMacro implements Macro {
    private PluginLicenseManager licenseManager;
    
    public MyBlockMacro(@ComponentImport("pluginLicenseManager") PluginLicenseManager pluginLicenseManager) {
        this.licenseManager = pluginLicenseManager;
    }
//....
}

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2016

I guess you need @Scanned above MyBlockMacro class.

Felipe Brandão Nascimento April 26, 2016

Mr Volodymyr, you saved my day =).

Thank you very much!!

I just feel bad I didn't find it anywhere around docs our other sources.

 

Richard Atkins
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2016

Spring scanner doesn't use component-import or component entries in atlassian-plugin.xml - you should also remove those, to save future confusion.

Spring scanner 2.x (available in the next Server release of Confluence) will save you ever having to use the Scanned annotation in future, but that's not available today for you to use in your plugin. For the moment, you need to put Scanned on any class that is using any other spring scanner annotations (ComponentImport, ConfluenceImport, ConfluenceComponent, ExportAsService).

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 26, 2016

Hi @Richard Atkins, It would be great if you put it to current spring-scanner docs. I myself hit this problem and I see that other developers face it again and again.

TAGS
AUG Leaders

Atlassian Community Events