Search code examples
javaspringosgiconfluence

Adding a <dependency> to my Atlassian plugin's pom.xml causes a Spring BundleException with a Constraint violation


I'm working on writing a plugin for Atlassian Confluence. I've had it working in a development environment for quite some time. But, when I package the plugin and deploye it into a test system the plugin fails to enable. I see the following cause / error message in the stack trace (included in entirety at the end of this question). I've formatted it for slightly easier reading:

Caused by: org.osgi.framework.BundleException: 
    Constraint violation for package 'org.springframework.transaction' when resolving module 200.0 between existing import 0.org.springframework.transaction 
    BLAMED ON 
        [
            [200.0] package; 
            (&(package=org.springframework.transaction)(version>=0.0.0)(version<=0.0.0))
        ] 
        and uses constraint 4.0.org.springframework.transaction
    BLAMED ON 
        [
            [200.0] package;
            (package=org.springframework.jms.connection)
        ]

I'm having trouble understanding what this is trying to tell me. The Confluence OSGi container debugging information indicates the following for the packages mentioned:

0 - System Bundle

4 - Spring Framework

200 - com.foo.ConflunceJMSIntegration (my plugin)

I am suspect this has something to do with class loaders used by the various modules, but I just don't know how to interpret the message or what to do to resolve the problem.

New information:

  • The plugin works with Confluence 5.5.4 but fails with 5.6.4.

  • I made a new empty generated plugin (atlas-create-confluence-plugin) and carefully added each of my dependencies to the pom.xml until I was able to produce the failure. The failure is clearly caused when I add this dependency:

    com.foo JMSTools 1.0-SNAPSHOT org.slf4j slf4j-api javax.mail mail log4j log4j

This is a library I wrote. While it doesn't use Spring for configuration itself, some objects implement org.springframework.beans.factory.DisposableBean and use org.springframework.util.StringUtils, so Spring is a legitimate requirement.

This is the dependency in JMSTools:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>2.5.6.SEC02</version>
    <scope>provided</scope>
</dependency>

And.... now that I type this out I see that Confluence 5.6.4 uses org.springframework:spring-core:jar:2.5.6.SEC03-atlassian-6:compile.

I just tried changing the version JMSTools is using to 2.5.6.SEC03 and it still did not resolve the problem. Even if it did, I'd be concerned that future updates Confluence might update Spring and break things again. My library isn't dependent on a specific version of Spring, it simply needs to implement/use the class and interface I mentioned before.

My current suspicion is that org.apache.activemq:activemq-all (a dependency of JMSTools) may be referencing the org.springframework.jms.connection for some reason, somehow causing the conflict. But.... I just don't know (yet).

Answers to Scott Dudley's questions:

(a) Confluence version:

5.6.4

(b) Dependency list from pom.xml (as printed by 'atlas-mvn dependency:tree'):

com.foo:ConflunceJMSIntegration:atlassian-plugin:1.0-SNAPSHOT
+- junit:junit:jar:4.10:test
|  \- org.hamcrest:hamcrest-core:jar:1.1:test
+- com.atlassian.confluence:confluence:jar:5.6.4:provided
|  +- com.atlassian.security:atlassian-secure-xml:jar:3.2.3:provided
|  +- com.atlassian.crowd:embedded-crowd-api:jar:2.7.1:provided
|  |  +- org.apache.commons:commons-lang3:jar:3.1:provided
|  |  \- com.google.code.findbugs:jsr305:jar:2.0.1:provided
|  +- com.atlassian.crowd:crowd-core:jar:2.7.1:provided
|  |  +- com.atlassian.crowd:crowd-api:jar:2.7.1:provided
|  |  +- com.atlassian.crowd:crowd-persistence-file:jar:2.7.1:provided
|  |  +- com.atlassian.crowd:crowd-events:jar:2.7.1:provided
|  |  \- com.atlassian.security:atlassian-secure-random:jar:3.2:provided
|  +- com.atlassian.crowd:crowd-integration-api:jar:2.7.1:provided
|  |  \- com.atlassian.ip:atlassian-ip:jar:3.1:provided
|  +- com.atlassian.crowd:crowd-integration-seraph25:jar:2.7.1:provided
|  |  \- com.atlassian.crowd:crowd-integration-client-common:jar:2.7.1:provided
|  +- com.atlassian.crowd:embedded-crowd-spi:jar:2.7.1:provided
|  +- com.atlassian.crowd:crowd-password-encoders:jar:2.7.1:provided
|  |  +- com.atlassian.security:atlassian-password-encoder:jar:3.2:provided
|  |  \- org.springframework.security:spring-security-core:jar:3.1.4.RELEASE:provided
|  +- com.atlassian.crowd:atlassian-embedded-crowd-atlassian-user:jar:1.7.3:provided
|  +- com.atlassian.crowd:embedded-crowd-core:jar:2.7.1:provided
|  |  \- com.atlassian.crowd:crowd-remote:jar:2.7.1:provided
|  |     \- com.atlassian.crowd:crowd-integration-client-rest:jar:2.7.1:provided
|  +- com.atlassian.crowd:crowd-persistence:jar:2.7.1:provided
|  +- com.atlassian.crowd:crowd-ldap:jar:2.7.1:provided
|  +- org.springframework.ldap:spring-ldap-core:jar:1.3.1.RELEASE:provided
|  +- com.atlassian.confluence:confluence-upgrade:jar:5.6.4:provided
|  +- com.atlassian.gzipfilter:atlassian-gzipfilter:jar:1.23:provided
|  |  +- javax.servlet:servlet-api:jar:2.3:provided
|  |  \- com.atlassian.gzipfilter:atlassian-flushable-gzipoutputstream:jar:1.1:provided
|  +- com.atlassian.analytics:analytics-api:jar:3.37:provided
|  +- com.atlassian.applinks:applinks-api:jar:4.2.3:provided
|  +- com.atlassian.applinks:applinks-spi:jar:4.2.3:provided
|  +- com.atlassian.applinks:applinks-host:jar:4.2.3:provided
|  +- com.atlassian.dragonfly:dragonfly-api:jar:1.1:provided
|  +- com.atlassian.dragonfly:dragonfly-spi:jar:1.1:provided
|  +- com.atlassian.dragonfly:dragonfly-core:jar:1.1:provided
|  +- com.atlassian.util.concurrent:atlassian-util-concurrent:jar:2.4.1:provided
|  +- com.atlassian.modzdetector:modz-detector:jar:0.8.1:provided
|  +- com.atlassian.mail:atlassian-mail:jar:2.5.0:provided
|  +- com.atlassian.velocity:atlassian-velocity:jar:1.3:provided
|  +- com.atlassian.core:atlassian-core:jar:4.6.11:provided
|  |  +- org.apache.sanselan:sanselan:jar:0.97-incubator:provided
|  |  +- com.atlassian.image:atlassian-image-consumer:jar:1.0.1:provided
|  |  \- javax.media:jai-core:jar:1.1.3:provided
|  +- com.atlassian.config:atlassian-config:jar:0.21:provided
|  +- com.atlassian.spring:atlassian-spring:jar:2.0.0:provided
|  +- com.atlassian.spring:atlassian-spring-hibernate2:jar:2.0.0:provided
|  +- com.atlassian.event:atlassian-event:jar:2.3.5:provided
|  +- com.atlassian.confluence:confluence-bucket:jar:5.6.4:provided
|  +- com.atlassian.hibernate:atlassian-hibernate2-extras:jar:4.1.1:provided
|  +- com.atlassian.xwork:atlassian-xwork-10:jar:1.17:provided
|  +- com.atlassian.xwork:atlassian-xwork-core:jar:1.17:provided
|  +- com.atlassian.profiling:atlassian-profiling:jar:1.9:provided
|  +- com.atlassian.threadlocal:atlassian-threadlocal:jar:1.4:provided
|  +- com.atlassian.trackback:atlassian-trackback:jar:0.10:provided
|  +- com.atlassian.extras:atlassian-extras-core:jar:3.2:provided
|  |  +- com.atlassian.extras:atlassian-extras-api:jar:3.2:provided
|  |  +- com.atlassian.extras:atlassian-extras-common:jar:3.2:provided
|  |  +- com.atlassian.extras:atlassian-extras-legacy:jar:3.2:provided
|  |  |  \- com.atlassian.extras:atlassian-extras-decoder-api:jar:3.2:provided
|  |  \- com.atlassian.extras:atlassian-extras-decoder-v2:jar:3.2:provided
|  +- com.atlassian.johnson:atlassian-johnson:jar:0.10:provided
|  +- com.atlassian.json:atlassian-json-jsonorg:jar:0.9:provided
|  |  \- com.atlassian.json:atlassian-json-api:jar:0.9:provided
|  +- com.atlassian.plugins:atlassian-plugins-core:jar:3.2.8:provided
|  |  \- com.atlassian.annotations:atlassian-annotations:jar:0.7:provided
|  +- com.atlassian.plugins:atlassian-plugins-servlet:jar:3.2.8:provided
|  +- com.atlassian.plugins:atlassian-plugins-webfragment:jar:3.0.1:provided
|  +- com.atlassian.plugins:atlassian-plugins-webresource:jar:3.1.1-PLUGWEB-85-m05:provided
|  |  +- com.atlassian.plugins:atlassian-plugins-webresource-common:jar:3.0.0:provided
|  |  +- com.atlassian.plugins:atlassian-plugins-webresource-api:jar:3.1.1-PLUGWEB-85-m05:provided
|  |  \- com.atlassian.html:atlassian-html-encoder:jar:1.4:provided
|  +- com.atlassian.plugins:atlassian-plugins-osgi:jar:3.2.8:provided
|  |  +- com.atlassian.plugins:atlassian-plugins-osgi-events:jar:3.2.8:provided
|  |  +- biz.aQute:bndlib:jar:1.43.0-atlassian-1:provided
|  |  +- org.apache.felix:org.apache.felix.framework:jar:3.0.2:provided
|  |  \- org.twdata.pkgscanner:package-scanner:jar:0.9.5:provided
|  +- com.atlassian.plugins:atlassian-plugins-schema:jar:3.2.8:provided
|  +- com.atlassian.plugins:atlassian-plugins-spring:jar:3.2.8:provided
|  +- com.atlassian.plugins:atlassian-spring-interceptor-adapter-spi:jar:1.1:provided
|  +- com.atlassian.bandana:atlassian-bandana:jar:3.1:provided
|  +- com.atlassian.user:atlassian-user:jar:3.0:provided
|  |  \- org.springframework:spring-dao:jar:2.0.6:provided
|  +- com.atlassian.renderer:atlassian-renderer-legacy:jar:6.2.10:provided
|  |  \- net.sourceforge.nekohtml:nekohtml:jar:1.9.7:provided
|  +- com.atlassian.bonnie:atlassian-bonnie:jar:6.1.2:provided
|  |  +- com.atlassian.bonnie:lucene-upgrader:jar:lucene36:1.0:provided
|  |  +- org.apache.pdfbox:pdfbox:jar:1.7.1:provided
|  |  |  +- org.apache.pdfbox:fontbox:jar:1.7.1:provided
|  |  |  \- org.apache.pdfbox:jempbox:jar:1.7.1:provided
|  |  \- com.ibm.icu:icu4j:jar:3.8:provided
|  +- org.bouncycastle:bcprov-jdk15on:jar:1.50:provided
|  +- org.bouncycastle:bcmail-jdk15on:jar:1.50:provided
|  |  \- org.bouncycastle:bcpkix-jdk15on:jar:1.50:provided
|  +- com.atlassian.jdk.utilities:atlassian-jdk-utilities:jar:0.4:provided
|  +- joda-time:joda-time:jar:2.3:provided
|  +- com.atlassian.seraph:atlassian-seraph:jar:3.0.0:provided
|  |  \- com.atlassian.security:atlassian-cookie-tools:jar:3.2.3:provided
|  +- com.atlassian.security.auth.trustedapps:atlassian-trusted-apps-core:jar:3.0.8:provided
|  +- com.atlassian.security.auth.trustedapps:atlassian-trusted-apps-seraph-integration:jar:3.0.8:provided
|  +- log4j:log4j:jar:1.2.15:provided
|  +- org.slf4j:slf4j-api:jar:1.7.7:provided
|  +- org.slf4j:slf4j-log4j12:jar:1.7.7:provided
|  +- org.slf4j:jul-to-slf4j:jar:1.7.7:provided
|  +- commons-lang:commons-lang:jar:2.6:provided
|  +- commons-logging:commons-logging:jar:1.1.3:compile
|  +- commons-io:commons-io:jar:1.4:provided
|  +- commons-beanutils:commons-beanutils:jar:1.8.3:provided
|  +- commons-fileupload:commons-fileupload:jar:1.3.1:provided
|  +- hibernate:hibernate:jar:2.1.8-atlassian-27:provided
|  +- cglib:cglib:jar:2.1_3:provided
|  |  \- asm:asm:jar:1.5.3:provided
|  +- dom4j:dom4j:jar:1.4-full:provided
|  +- odmg:odmg:jar:3.0:provided
|  +- c3p0:c3p0:jar:0.9.1.2:provided
|  +- javax.transaction:jta:jar:1.0.1B:provided
|  +- com.sun:jai_core:jar:1.1.3:provided
|  +- com.sun:jai_codec:jar:1.1.3:provided
|  +- opensymphony:webwork:jar:2.1.5-atlassian-2:provided
|  +- opensymphony:xwork:jar:1.0.3.6:provided
|  +- ognl:ognl:jar:2.6.5-atlassian-2:provided
|  +- opensymphony:oscore:jar:2.2.7-atlassian-1:provided
|  +- oscache:oscache:jar:2.2:provided
|  +- osuser:osuser:jar:atl.user:provided
|  +- opensymphony:propertyset:jar:1.3-21Nov03:provided
|  +- org.apache.velocity:velocity:jar:1.6.4-atlassian-1:provided
|  +- com.atlassian.soy:soy-template-renderer-api:jar:2.8.0:provided
|  +- commons-pool:commons-pool:jar:1.5.4:provided
|  +- javax.mail:mail:jar:1.4.5:provided
|  +- org.springframework:spring-core:jar:2.5.6.SEC03-atlassian-6:compile
|  +- org.springframework:spring-web:jar:2.5.6.SEC03:provided
|  +- org.springframework:spring-aop:jar:2.5.6.SEC03:provided
|  |  \- aopalliance:aopalliance:jar:1.0:provided
|  +- org.springframework:spring-hibernate2:jar:2.5.6-atlassian-1:provided
|  |  \- org.springframework:spring-orm:jar:2.5.6:provided
|  +- org.springframework:spring-beans:jar:2.5.6.SEC03:compile
|  +- org.springframework:spring-jdbc:jar:2.5.6.SEC03:provided
|  +- org.springframework:spring-context:jar:2.5.6.SEC03:provided
|  +- org.springframework:spring-tx:jar:2.5.6.SEC03:provided
|  +- org.springframework:spring-context-support:jar:2.5.6.SEC03:provided
|  +- com.atlassian.paddle:atlassian-paddle:jar:5:provided
|  +- org.aspectj:aspectjweaver:jar:1.6.0:provided
|  +- net.sf.ldaptemplate:ldaptemplate:jar:1.0.1:provided
|  +- opensymphony:sitemesh:jar:2.5-atlassian-6:provided
|  +- velocity-tools:velocity-tools:jar:view-1.1:provided
|  +- radeox:radeox:jar:1.0b2-forked-22Apr2004:provided
|  +- org.apache.lucene:lucene-core:jar:4.4.0:provided
|  +- org.apache.lucene:lucene-analyzers-common:jar:4.4.0:provided
|  +- org.apache.lucene:lucene-analyzers-kuromoji:jar:4.4.0:provided
|  +- org.apache.lucene:lucene-misc:jar:4.4.0:provided
|  +- org.apache.lucene:lucene-highlighter:jar:4.4.0:provided
|  |  +- org.apache.lucene:lucene-memory:jar:4.4.0:provided
|  |  \- org.apache.lucene:lucene-queries:jar:4.4.0:provided
|  +- org.apache.lucene:lucene-queryparser:jar:4.4.0:provided
|  |  \- org.apache.lucene:lucene-sandbox:jar:4.4.0:provided
|  |     \- jakarta-regexp:jakarta-regexp:jar:1.4:provided
|  +- commons-digester:commons-digester:jar:1.5:provided
|  +- net.sourceforge.cssparser:cssparser:jar:0.9.5:provided
|  |  \- org.w3c.css:sac:jar:1.3:provided
|  +- org.hibernate:jtidy:jar:r8-20060801:provided
|  +- org.quartz-scheduler:quartz:jar:1.8.0:provided
|  +- org.hsqldb:hsqldb:jar:2.3.0:provided
|  +- com.atlassian.hsqldb:atlassian-hsqdlb-server-integration:jar:1.1.0:provided
|  +- rome:rome:jar:1.0:provided
|  +- jdom:jdom:jar:1.0:provided
|  +- commons-jrcs:commons-jrcs:jar:diff-0.1.7:provided
|  +- commons-httpclient:commons-httpclient:jar:3.1:provided
|  +- xerces:xercesImpl:jar:2.11.0:provided
|  +- xmlrpc:xmlrpc:jar:2.0+xmlrpc61.1+sbfix:provided
|  +- com.atlassian.xmlrpc:xmlrpc-supplementary-character-support:jar:0.2:provided
|  +- commons-discovery:commons-discovery:jar:0.2:provided
|  +- commons-codec:commons-codec:jar:1.8:provided
|  +- oro:oro:jar:2.0.8:provided
|  +- slide:slide:jar:2.1:provided
|  +- com.thoughtworks.xstream:xstream:jar:1.1.1:provided
|  |  \- xpp3:xpp3_min:jar:1.1.3.4.O:provided
|  +- jfree:jfreechart:jar:1.0.0:provided
|  |  \- jfree:jcommon:jar:1.0.0:provided
|  +- xalan:xalan:jar:2.7.1:provided
|  |  \- xalan:serializer:jar:2.7.1:provided
|  +- com.octo.captcha:jcaptcha-all:jar:1.0-RC6:provided
|  |  \- concurrent:concurrent:jar:1.3.4:provided
|  +- org.tuckey:urlrewritefilter:jar:4.0.4:provided
|  +- commons-collections:commons-collections:jar:3.2.1:provided
|  +- javax.xml.stream:stax-api:jar:1.0-2:provided
|  +- org.codehaus.woodstox:wstx-asl:jar:3.2.9-atlassian-1:provided
|  +- org.codehaus.xfire:xfire-core:jar:1.2.6:provided
|  |  +- wsdl4j:wsdl4j:jar:1.6.1:provided
|  |  \- org.apache.ws.commons:XmlSchema:jar:1.1:provided
|  +- org.codehaus.xfire:xfire-aegis:jar:1.2.6:provided
|  |  \- net.java.dev.stax-utils:stax-utils:jar:20040917:provided
|  +- net.jcip:jcip-annotations:jar:1.0:provided
|  +- com.atlassian.cache:atlassian-cache-api:jar:2.3.4:provided
|  +- com.atlassian.cache:atlassian-cache-memory:jar:2.3.4:provided
|  |  \- com.atlassian.cache:atlassian-cache-common-impl:jar:2.3.4:provided
|  +- com.atlassian.beehive:beehive-api:jar:0.1.3:provided
|  +- com.atlassian.sal:sal-spi:jar:2.12.1:provided
|  +- com.atlassian.sal:sal-spring:jar:2.12.1:provided
|  +- com.atlassian.sal:sal-api:jar:2.12.1:provided
|  +- com.atlassian.confluence:confluence-java-api:jar:5.6.4:provided
|  +- com.atlassian.confluence:confluence-rest-api:jar:5.6.4:provided
|  +- com.atlassian.confluence:confluence-rest-serialization:jar:5.6.4:provided
|  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.1:provided
|  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.1:provided
|  +- com.atlassian.activeobjects:activeobjects-dbex:jar:0.28.2:provided
|  |  \- com.atlassian.activeobjects:activeobjects-spi:jar:0.28.2:provided
|  +- org.owasp.antisamy:antisamy:jar:1.4.2-atlassian-13:provided
|  |  \- org.apache.xmlgraphics:batik-css:jar:1.7:provided
|  |     +- org.apache.xmlgraphics:batik-ext:jar:1.7:provided
|  |     \- org.apache.xmlgraphics:batik-util:jar:1.7:provided
|  +- org.outerj.daisy:daisydiff:jar:1.1-atlassian-5:provided
|  |  \- org.eclipse.core:runtime:jar:20070801:provided
|  +- com.atlassian.velocity.htmlsafe:velocity-htmlsafe:jar:1.2-fixedscm:provided
|  +- com.atlassian.botocss:botocss-core:jar:4.3:provided
|  |  +- org.jsoup:jsoup:jar:1.7.2:provided
|  |  +- net.sourceforge.cssbox:jstyleparser:jar:1.13-atlassian-2:provided
|  |  \- org.antlr:antlr-runtime:jar:3.4:provided
|  |     +- org.antlr:stringtemplate:jar:3.2.1:provided
|  |     \- antlr:antlr:jar:2.7.7:provided
|  +- com.google.guava:guava:jar:11.0.2:provided
|  +- com.atlassian.fugue:fugue:jar:1.1:provided
|  +- com.google.code.gson:gson:jar:1.6:provided
|  +- com.atlassian.http:atlassian-http:jar:0.0.8.8:provided
|  +- org.javasimon:javasimon-core:jar:3.4.0:provided
|  \- com.atlassian.tenancy:atlassian-tenancy-api:jar:1.4.1:provided
+- com.atlassian.confluence.plugins:confluence-rpc-plugin:jar:5.6.4:provided
+- com.atlassian.plugins:atlassian-plugins-osgi-testrunner:jar:1.2.0:test
+- javax.ws.rs:jsr311-api:jar:1.1.1:provided
+- javax.xml.bind:jaxb-api:jar:2.2:provided
+- org.mockito:mockito-all:jar:1.8.5:test
+- com.foo:JMSTools:jar:1.0-SNAPSHOT:compile
|  +- org.apache.activemq:activemq-all:jar:5.10.0:compile
|  \- org.apache.activemq:activemq-jaas:jar:5.10.0:compile
+- com.atlassian.confluence.plugins:confluence-space-ia:jar:8.3:provided
+- com.atlassian.activeobjects:activeobjects-core:jar:0.25.2:provided
|  \- net.java.dev.activeobjects:activeobjects:jar:0.25.2:provided
+- com.atlassian.confluence.plugins:doctheme:jar:5.6.3:provided
+- com.atlassian.applinks:applinks-core:jar:2.5.12:provided
+- com.atlassian.applinks:applinks-plugin:jar:4.1.2:provided
+- com.atlassian.plugins.rest:atlassian-rest-common:jar:1.0.2:provided
|  +- com.atlassian.plugins.rest:com.atlassian.jersey-library:pom:1.0.2:provided
|  |  +- com.sun.jersey:jersey-server:jar:1.0.3:provided
|  |  |  \- com.sun.jersey:jersey-core:jar:1.0.3:provided
|  |  \- com.sun.jersey:jersey-json:jar:1.0.3:provided
|  |     +- org.codehaus.jettison:jettison:jar:1.0.1:provided
|  |     \- org.codehaus.jackson:jackson-asl:jar:0.9.4:provided
|  \- net.sourceforge.findbugs:jsr305:jar:1.3.2:provided
+- org.apache.wink:wink-client:jar:1.1.3-incubating:test
|  +- org.apache.wink:wink-common:jar:1.1.3-incubating:test
|  |  \- org.apache.geronimo.specs:geronimo-annotation_1.1_spec:jar:1.0:test
|  +- com.sun.xml.bind:jaxb-impl:jar:2.2.1.1:test
|  \- javax.activation:activation:jar:1.1:provided
+- org.apache.httpcomponents:httpclient:jar:4.1.1:test
|  \- org.apache.httpcomponents:httpcore:jar:4.1:test
+- org.powermock:powermock-module-junit4:jar:1.4.9:test
|  \- org.powermock:powermock-module-junit4-common:jar:1.4.9:test
|     +- org.powermock:powermock-core:jar:1.4.9:test
|     |  \- org.javassist:javassist:jar:3.14.0-GA:test
|     \- org.powermock:powermock-reflect:jar:1.4.9:test
|        \- org.objenesis:objenesis:jar:1.2:test
\- org.powermock:powermock-api-mockito:jar:1.4.9:test
   \- org.powermock:powermock-api-support:jar:1.4.9:test

(c) Component Imports:

From atlassian-plugin.xml:

<component-import key="transactionTemplate" 
                  interface="com.atlassian.sal.api.transaction.TransactionTemplate"/>
<component-import key="sidebar-link-service"
                  interface="com.atlassian.confluence.plugins.ia.service.SidebarLinkService"/>
<component-import key="userManager" 
                  interface="com.atlassian.user.UserManager"/>
<component-import key="systemTemplateManager" 
                  interface="com.atlassian.confluence.spaces.SystemTemplateManager"/>
<component-import key="fileUploadManager" 
                  interface="com.atlassian.confluence.pages.FileUploadManager"/>
<component-import key="entityLinkService" 
                  interface="com.atlassian.applinks.spi.link.MutatingEntityLinkService"/>
<component-import key="applicationLinkService" 
                  interface="com.atlassian.applinks.api.ApplicationLinkService"/>
<component-import key="typeAccessor" 
                  interface="com.atlassian.applinks.spi.util.TypeAccessor"/>
<component-import key="entityLinkBuilderFactory" 
                  interface="com.atlassian.applinks.spi.link.EntityLinkBuilderFactory"/>
<component-import key="applicationProperties" 
                  interface="com.atlassian.sal.api.ApplicationProperties"/>
<component-import key="licenseService" 
                  interface="com.atlassian.confluence.license.LicenseService"/>
<component-import key="i18nResolver" 
                  interface="com.atlassian.sal.api.message.I18nResolver"/>
<component-import key="loginUriProvider" 
                  interface="com.atlassian.sal.api.auth.LoginUriProvider"/>
<component-import key="soyTemplateRenderer" 
                  interface="com.atlassian.soy.renderer.SoyTemplateRenderer" />
<component-import name="Plugin Settings Factory" key="pluginSettingsFactory" 
                  interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory"/>

From META-INF/spring/atlassian-plugin-context.xml:

<osgi:reference id="transactionTemplate"
                interface="com.atlassian.sal.api.transaction.TransactionTemplate" />
<osgi:reference id="sidebarLinkService"
                interface="com.atlassian.confluence.plugins.ia.service.SidebarLinkService" />
<osgi:reference id="userManager"
                interface="com.atlassian.user.UserManager" />
<osgi:reference id="systemTemplateManager"
                interface="com.atlassian.confluence.spaces.SystemTemplateManager" />
<osgi:reference id="fileUploadManager"
                interface="com.atlassian.confluence.pages.FileUploadManager" />
<osgi:reference id="entityLinkService"
                interface="com.atlassian.applinks.spi.link.MutatingEntityLinkService"/>
<osgi:reference id="applicationLinkService"
                interface="com.atlassian.applinks.api.ApplicationLinkService"/>
<osgi:reference id="typeAccessor"
                interface="com.atlassian.applinks.spi.util.TypeAccessor"/>
<osgi:reference id="entityLinkBuilderFactory"
                interface="com.atlassian.applinks.spi.link.EntityLinkBuilderFactory"/>
<osgi:reference id="pluginSettingsFactory"
                interface="com.atlassian.sal.api.pluginsettings.PluginSettingsFactory" />
<osgi:reference id="spaceManager"
                interface="com.atlassian.confluence.spaces.SpaceManager" />
<osgi:reference id="pageManager"
                interface="com.atlassian.confluence.pages.PageManager" />

Note: I need to check to make sure that I still need all of these imports / references. I'm also not sure if I need to have the component-import in the atlassian-plugin.xml to reference them in the atlassian-plugin-context.xml. If not, I may be able to clean up these lists a bit.

(d) components where public=true:

<component key="confluence-event-listener" class="com.foo.confluence.ConfluenceJMSAnnouncerImpl"
           name="Confluence Event Listener" i18n-name-key="confluence-event-listener.name" public="true">
    <description key="confluence-event-listener.description">The confluence event listener Impl Plugin</description>
    <interface>com.foo.confluence.ConfluenceJMSAnnouncer</interface>
</component>

Note: I suspect this doesn't need to be public.

Second note: I have 30 beans configured in the atlassian-plugin-context.xml. The only one I expose is:

<osgi:service interface="com.foo.confluence.ConfluenceService" ref="confluenceService"/>

Full stack trace:

2014-10-30 09:29:25,451 ERROR [main] [plugin.osgi.factory.OsgiPlugin] enableInternal Detected an error (BundleException) enabling the plugin 'com.foo.ConflunceJMSIntegration' : Constraint violation for package 'org.springframework.transaction' when resolving module 201.0 between existing import 0.org.springframework.transaction BLAMED ON [[201.0] package; (&(package=org.springframework.transaction)(version>=0.0.0)(version<=0.0.0))] and uses constraint 4.0.org.springframework.transaction BLAMED ON [[201.0] package; (package=org.springframework.jms.connection)].  This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
2014-10-30 09:29:25,452 WARN [main] [atlassian.plugin.impl.AbstractPlugin] enable Unable to enable plugin 'com.foo.ConflunceJMSIntegration'
2014-10-30 09:29:25,454 WARN [main] [atlassian.plugin.impl.AbstractPlugin] enable Because of this exception
com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.foo.ConflunceJMSIntegration
    at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:479)
    at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:310)
    at com.atlassian.plugin.impl.AbstractDelegatingPlugin.enable(AbstractDelegatingPlugin.java:242)
    at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:136)
    at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:104)
.... had to remove detail to trim length of question ....
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.osgi.framework.BundleException: Constraint violation for package 'org.springframework.transaction' when resolving module 201.0 between existing import 0.org.springframework.transaction BLAMED ON [[201.0] package; (&(package=org.springframework.transaction)(version>=0.0.0)(version<=0.0.0))] and uses constraint 4.0.org.springframework.transaction BLAMED ON [[201.0] package; (package=org.springframework.jms.connection)]
    at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3415)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1709)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
    at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:456)
    ... 33 more
2014-10-30 09:29:25,455 ERROR [main] [atlassian.plugin.manager.PluginEnabler] actualEnable Unable to enable plugin com.foo.ConflunceJMSIntegration
com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.foo.ConflunceJMSIntegration
    at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:479)
    at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:310)
.... had to remove detail to trim length of question ....
Caused by: org.osgi.framework.BundleException: Constraint violation for package 'org.springframework.transaction' when resolving module 201.0 between existing import 0.org.springframework.transaction BLAMED ON [[201.0] package; (&(package=org.springframework.transaction)(version>=0.0.0)(version<=0.0.0))] and uses constraint 4.0.org.springframework.transaction BLAMED ON [[201.0] package; (package=org.springframework.jms.connection)]
    at org.apache.felix.framework.Felix.resolveBundle(Felix.java:3415)
    at org.apache.felix.framework.Felix.startBundle(Felix.java:1709)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:905)
    at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:892)
    at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:456)
    ... 33 more

Solution

  • Merely adding <dependency> entries to the pom.xml in an otherwise-empty plugin should not generally cause OSGi errors on plugin load, since Confluence should not be trying to import external packages merely based on the presence of a dependency.

    My suspicion (confirmed in the chat thread) is that one of your dependencies is including some sort of Spring instructions that is confusing Confluence on plugin load. When a plugin is built using the defaults, the plugin SDK will automatically un-JAR all of the dependencies and include the resulting set of files in the main plugin JAR.

    If one of your library dependencies inadvertently included Spring-related data in META-INF/spring or elsewhere, this would get intermingled with your own plugin's Spring configuration, which can wreak havoc.

    The best way to solve this is to disable dependency extraction. This means that instead of un-JARring all of your dependencies and dumping them in the same JAR as your plugin, the dependencies are left in their source JARs and those JARs are included directly in META-INF/lib. Even if the dependencies do declare some rogue Spring instructions, they will remain in their own JAR and they will not be processed by Confluence when loading your plugin.

    To disable the extraction of dependencies, you will want to set extractDependencies to false in the confluence-maven-plugin section of your pom.xml, as shown below:

    <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-conflue‌​‌​nce-plugin</artifactId>
        <version>x.y.z</version>
        [...]
        <configuration>
            [...]
            <extractDependencies>false</extractDependencies>
        </configuration>
    </plugin>