last day (21 days later) » 

6:23 PM
0
Q: How do I interpret this osgi constraint violation when resolving module error message?

Doug HughesI'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 en...

 
Do you have any explicit OSGi import instructions in your pom.xml or atlassian-plugins.xml? If so, can you please post them? (Also, you seem to have omitted the stack trace at the end of the post.) My read of the error is that v4 of the Spring transaction package is supplied, but perhaps you have supplied a constraint of "[0.0.0,0.0.0]" that specifically excludes it.
 
D'oh, I did forget the stack trace. Sorry about that. (I'll update the question once I get my app back to a point where I get this specific error again.) I do not have any OSGi import instructions in either my pom.xml or atlassian-plugins.xml. From what I can tell, Confluence itself loads (provides? I'm not sure of the terminology here) org.springframework.transaction in the system bundle and the spring framework bundle. They do have different versions. Note, I think that the 4.0.org.springframework.transaction refers to bundle 4, not version 4.
 
Oh—I think you're right about the "4". If you don't supply specific OSGi bundle instructions, then Confluence builds them automatically on plugin install by scanning your JAR. On top of the stack trace, can you please also post: (a) your Confluence version, (b) your <dependency> list from your pom.xml, (c) <component-import>s from your atlassian-plugin.xml, and (d) any <component> from your atlassian-plugin.xml where public=true?
I notice also the "uses constraint" mention in the error. This one is new OSGi territory for me too, but this looks related: njbartlett.name/2011/09/02/uses-constraints.html
 
Scott, I've edited the question to add new information and to answer your questions. I'll give that link a read too. Thanks for your help!
 
What's the reason for having your own META-INF/spring/atlassian-plugin-context.xml file? (The component-import in your atlassian-plugin.xml will automatically take care of imports for the named components. Additionally, every component of your own in atlassian-plugin.xml is automatically instantiated as a bean, whether or not it's public.) Are you doing anything else with that requires this file?
Also, did your empty atlas-create-confluence-plugin plugin have anything in META-INF/spring? Did you change anything in the project except the pom? (A certain amount of ninja action involves anything in that folder, since Confluence does its own relatively-obscure OSGi transformation at runtime when loading the plugin, and placing certain files or configuring certain attributes there can sometimes inhibit the behavior you would otherwise expect.)
One hunch: if just adding the dep to the pom.xml causes problems, try setting extractDependencies=false in the confluence-plugin config, like shown below. After making this edit, make sure to nuke target/classes before doing a full rebuild. <plugin><groupId>com.atlassian.maven.plugins</groupId><artifactId>maven-conflue‌​‌​nce-plugin</artifactId><version>x.y.z</version>[...]<configuration> [...] <extractDependencies>false</extractDependencies></configuration></plugin>
 
6:23 PM
I am using the atlassian-plugin-context.xml because I use spring xml to configure several classes in ways that (I think) you can't using atlassian-plugin.xml. For example, I have 13 instances of com.foo.jms.Consumer configured to listen for different JMS messages. Those are wired to call methods on configured message handlers. I don't know of a way to do this type of config using the atlassian-plugin.xml XML alone.
No, my empty atlas-create-confluence-plugin plugin did not have anything META-INF/spring. I only changed the pom.xml dependencies.
I'm not sure what you mean regarding the use of extractDependencies=false. I'm researching that now and will report back once I've figured it out.
 
You'll find that <plugin> entry already in your pom.xml. What I mean is to add the extractDependencies line to the configuration.
Adding a dependency to the pom generally shouldn't provoke any errors from Spring. My suspicion is that your bundled library contains some files in META-INF/spring. With the default extractDependencies value, these files get unjarred and tossed into your main plugin JAR, which can then potentially confuse the Spring loader in Confluence. Setting that to false leaves the library JAR as-is.
 
6:37 PM
I've added the extractDependencies=false to the pom.xml and I think it worked. I did this at the same time as another small tweak so I'm confirming that this is the case.
Nope, it appears that the resolution was to add this in the configuration block: <instructions>
<Export-Package>
com.dadco
</Export-Package>
</instructions>
But wow. That was just a lucky guess on my part.
 
Out of curiosity, did you try it with only extractDeps=false and not the export-package?
and wipe your build directory between attempts?
 
I'll test that now too, to be sure.
I'm pulling up the working plugin via Confluence now to make sure it's actually working. Then I'll make the requested change and try again.
Yes, that also worked!
I'm quite thrilled! I can not thank you enough for your help. I feel like I should send you some flowers or something. ;)
 
6:54 PM
To confirm my suspicion, if you do "jar tvf my_bad_library_dep.jar | grep META-INF/spring" then you get a non-zero list of files, right? (To be run on the JAR that you are including in the dep, not in your plugin jar.)
I'd even take just an accept+upvote, if I write this up as an answer :-)
 
Well, no. I was doing that check (jar -tf) beforehand on the JMSTools library and spring wasn't in there at all. All that was in the JMSTools jar were my packages and classes, maven metadata, and a manifest.
And heck yes, I'll give you an accept and upvote!
 
I still feel like it still has to be something in the META-INF. An interesting thing to try would be building with extract-deps=false, then running the "jar tvf | grep" command on the final JAR. Then build again with the dependencies extracted, do another jar tvf | grep, and see if anything changed.
 
Why not. Give me a few to do so
 
(Adding to the pom will add things to the JAR, but this should not generally result in anything fancy happening at the spring component level. Although Atlassian has admittedly been messing around with more dynamic JAR-scanning recently, so I guess it's possible something along these lines changed in 5.6...but it still smells funny.)
No one likes an answer that solves a problem without knowing exactly why it solves the problem :-)
 
Well, I've used the same library in Jira and Stash plugins w/o similar problems. I'm not sure if Confluence 5.6 is newer than the the latest Jira and Stash releases.
 
7:05 PM
Plugin framework across apps is kind of a cluster. This hasn't been updated recently, but it gives you an idea: developer.atlassian.com/display/DOCS/…
 
Oh, I'm not writing one plugin to cross multiple apps. That idea died in the first week of this project. I just have three plugins that are all using the JMSTools library that I abstracted out.
Ok, so here's what I'm seeing. W/O extract-deps=false, the generated Jar seems to have included all the classes from it's dependencies directly. With extract-deps=false I get jars containing the requirements.
crap, I think I've got that backwards.
yea, I do. when I add extract deps I get a much smaller number of files in my jar. In particular, it doesn't include all of the dependencies packages and classes. So, for example, I get META-INF/lib/JMSTools-1.0-SNAPSHOT.jar instead of all the packages and classes that make up JMSTools.
What this means is that when I didn't use extract deps = false, I get all of the classes from activemq and it's dependencies (javax.jms, javax.transaction, and a lot more)
I also get all the poms in the maven metadata. now I only get my own plugin's metadata
in a nutshell, there's a ton of crap in META-INF when I don't use extract-deps=false.
However, none of these were anything from org.springframework. I think that must have been a red hearing.
 
7:24 PM
It's expected that the extract-deps=true will explode all of the *.class files and everything else, and extract-deps=false will just include the .jars of the dependencies. The ton of crap in META-INF is what I think is responsible for the Spring loading, even if it doesn't directly mention org.springframework. If you really wanted to see what caused the problem, you could try manipulating the JAR with the extracted dependencies (which does not work) and see if deleting all of the
META-INF stuff (except your own plugin's main files) makes it work. This will let you bisect whether it's a problem with some random META-INF thing breaking things, or if it's something related to one of the exploded .class files that is being bytecode-scanned at runtime.
 
Ok. I may as well. Again, give me a few.
Happen to know of a way to run confluence via atlas-mvn that won't rebuild the plugin?
 
I usually set up a standalone version of Confluence that is run separately, and then use atlas-cli's "pi" command to upload the plugin when I want it. e.g. to talk to a COnfluence running on localhost at port 8090, use: atlas-cli -p 8090 --context-path ""
(using "pi" requires you have a user in confluence named "admin" with pass "admin")
 
gotcha. I just spun up a test instance on a VM so I'm already almost there. But that's good info none the less
 
7:49 PM
Well, I think I borked up the plugin by directly manipulating the jar. But, at this point I need to get some stuff done so I can't put more time towards this unfortunately.
Again, thank you VERY much for your help. I couldn't have done it without you.
 
OK. glad that it all got working in the end! I'll post a brief summary to the question, even if we didn't find the exact file in the unbundled JAR that was borking things.
OK, answered. Good luck with the rest of your project!
 

  last day (21 days later) »