org.osgi.framework.BundleException: Uses constraint violation

Hi, I am developing a plugin of confluence server. When I used atlas-run command to run my local test environment, I couldn’t load my plugin because of the following error. And I don’t know what’s going on.

[INFO] [talledLocalContainer] Caused by: org.osgi.framework.BundleException: Uses constraint violation. Unable to resolve resource com.fr.atlassian.finenotifysystem [com.fr.atlassian.finenotifysystem [301](R 301.0)] because it is exposed to package 'org.springframework.lang' from resources org.apache.felix.framework [org.apache.felix.framework [0](R 0)] and org.apache.servicemix.bundles.spring-core [org.apache.servicemix.bundles.spring-core [5](R 5.0)] via two dependency chains.
[INFO] [talledLocalContainer] Chain 1:
[INFO] [talledLocalContainer]   com.fr.atlassian.finenotifysystem [com.fr.atlassian.finenotifysystem [301](R 301.0)]
[INFO] [talledLocalContainer]     import: (&(osgi.wiring.package=org.springframework.lang)(version>=0.0.0)(version<=0.0.0))
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package: org.springframework.lang
[INFO] [talledLocalContainer]   org.apache.felix.framework [org.apache.felix.framework [0](R 0)]
[INFO] [talledLocalContainer] 
[INFO] [talledLocalContainer] Chain 2:
[INFO] [talledLocalContainer]   com.fr.atlassian.finenotifysystem [com.fr.atlassian.finenotifysystem [301](R 301.0)]
[INFO] [talledLocalContainer]     import: (osgi.wiring.package=com.atlassian.plugin.osgi.bridge.external)
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package=com.atlassian.plugin.osgi.bridge.external; uses:=org.eclipse.gemini.blueprint.context
[INFO] [talledLocalContainer]   com.atlassian.plugin.osgi.bridge [com.atlassian.plugin.osgi.bridge [15](R 15.0)]
[INFO] [talledLocalContainer]     import: (&(osgi.wiring.package=org.eclipse.gemini.blueprint.context)(version>=3.0.0))
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package=org.eclipse.gemini.blueprint.context; uses:=org.springframework.context
[INFO] [talledLocalContainer]   org.eclipse.gemini.blueprint.core [org.eclipse.gemini.blueprint.core [2](R 2.0)]
[INFO] [talledLocalContainer]     import: (&(osgi.wiring.package=org.springframework.context)(version>=5.0.0)(!(version>=6.0.0)))
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package=org.springframework.context; uses:=org.springframework.beans
[INFO] [talledLocalContainer]   org.apache.servicemix.bundles.spring-context [org.apache.servicemix.bundles.spring-context [16](R 16.0)]
[INFO] [talledLocalContainer]     import: (&(osgi.wiring.package=org.springframework.beans)(version>=5.1.8.RELEASE)(!(version>=5.2.0)))
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package=org.springframework.beans; uses:=org.springframework.core
[INFO] [talledLocalContainer]   org.apache.servicemix.bundles.spring-beans [org.apache.servicemix.bundles.spring-beans [8](R 8.0)]
[INFO] [talledLocalContainer]     import: (&(osgi.wiring.package=org.springframework.core)(version>=5.1.8.RELEASE)(!(version>=5.2.0)))
[INFO] [talledLocalContainer]      |
[INFO] [talledLocalContainer]     export: osgi.wiring.package: org.springframework.core; uses:=org.springframework.lang
[INFO] [talledLocalContainer]     export: osgi.wiring.package=org.springframework.lang
[INFO] [talledLocalContainer]   org.apache.servicemix.bundles.spring-core [org.apache.servicemix.bundles.spring-core [5](R 5.0)] Unresolved requirements: [[com.fr.atlassian.finenotifysystem [301](R 301.0)] osgi.wiring.package; (osgi.wiring.package=com.atlassian.plugin.osgi.bridge.external)]
[INFO] [talledLocalContainer]   at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.Felix.startBundle(Felix.java:2119)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
[INFO] [talledLocalContainer]   at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:405)
[INFO] [talledLocalContainer]   ... 64 more
[INFO] [talledLocalContainer] 2020-06-28 10:30:22,556 ERROR [QuickReload - Plugin Installer] [atlassian.plugin.manager.PluginEnabler] actualEnable Unable to enable plugin com.fr.atlassian.finenotifysystem
[INFO] [talledLocalContainer] com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.fr.atlassian.finenotifysystem
[INFO] [talledLocalContainer]   at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:424)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:252)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:120)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:97)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.lambda$enableDependentPlugins$22(DefaultPluginManager.java:1246)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginTransactionContext.wrap(PluginTransactionContext.java:63)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1230)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.lambda$addPlugins$20(DefaultPluginManager.java:1215)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginTransactionContext.wrap(PluginTransactionContext.java:63)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1115)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.lambda$scanForNewPlugins$12(DefaultPluginManager.java:920)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginTransactionContext.wrap(PluginTransactionContext.java:63)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.scanForNewPlugins(DefaultPluginManager.java:875)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.lambda$installPlugins$11(DefaultPluginManager.java:835)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.PluginTransactionContext.wrap(PluginTransactionContext.java:63)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.manager.DefaultPluginManager.installPlugins(DefaultPluginManager.java:821)
[INFO] [talledLocalContainer]   at com.atlassian.confluence.plugin.EventDispatchingPluginController.installPlugins(EventDispatchingPluginController.java:74)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
[INFO] [talledLocalContainer]   at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:295)
[INFO] [talledLocalContainer]   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
[INFO] [talledLocalContainer]   at com.sun.proxy.$Proxy227.installPlugins(Unknown Source)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer]   at com.atlassian.plugin.util.ContextClassLoaderSettingInvocationHandler.invoke(ContextClassLoaderSettingInvocationHandler.java:26)
[INFO] [talledLocalContainer]   at com.sun.proxy.$Proxy464.installPlugins(Unknown Source)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[INFO] [talledLocalContainer]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
[INFO] [talledLocalContainer]   at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:56)
[INFO] [talledLocalContainer]   at org.eclipse.gemini.blueprint.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:60)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:70)
[INFO] [talledLocalContainer]   at org.eclipse.gemini.blueprint.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:53)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.eclipse.gemini.blueprint.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:57)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
[INFO] [talledLocalContainer]   at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
[INFO] [talledLocalContainer]   at com.sun.proxy.$Proxy2589.installPlugins(Unknown Source)
[INFO] [talledLocalContainer]   at com.atlassian.labs.plugins.quickreload.install.PluginInstallerMechanic.installPluginImmediately(PluginInstallerMechanic.java:142)
[INFO] [talledLocalContainer]   at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.installPluginImmediately(PluginInstaller.java:307)
[INFO] [talledLocalContainer]   at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.attemptInstall(PluginInstaller.java:299)
[INFO] [talledLocalContainer]   at com.atlassian.labs.plugins.quickreload.install.PluginInstaller.loopWaitingForInstallPromises(PluginInstaller.java:209)
[INFO] [talledLocalContainer]   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[INFO] [talledLocalContainer]   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[INFO] [talledLocalContainer]   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[INFO] [talledLocalContainer]   at java.lang.Thread.run(Thread.java:748)

Here is my dependencies and build configuration in Maven POM.xml

<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
            <version>${atlassian.spring.scanner.version}</version>
            <scope>provided</scope>
        </dependency>



        <!-- WIRED TEST RUNNER DEPENDENCIES -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-testrunner</artifactId>
            <version>${plugin.testrunner.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.mywork</groupId>
            <artifactId>mywork-api</artifactId>
            <version>1.0.2</version>
            <scope>provided</scope>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <allowGoogleTracking>false</allowGoogleTracking>
                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <!--<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>-->

                        <!-- Add package to export here -->
                        <!--<Export-Package>-->
                        <!--com.fr.atlassian.confluence.score.api,-->
                        <!--</Export-Package>-->

                        <!-- Add package import here -->
                        <Import-Package>
                            org.springframework.osgi.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",
                            *
                        </Import-Package>

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <dependency>
                            <groupId>com.atlassian.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <properties>
        <confluence.version>7.2.2</confluence.version>
        <confluence.data.version>6.10.1</confluence.data.version>
        <amps.version>8.0.2</amps.version>
        <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
        <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

Might be related to the old Spring Scanner. You should use the newer one (2.x,
https://bitbucket.org/atlassian/atlassian-spring-scanner/src/master/)

There is another question around here, seems to be something “outdated” with the add-on boilerplate.