I've just been through a lot of grief installing activemq on Debian Wheezy. apt-get install activemq
installed a lot of packages - openjdk-jre + a raft of libraries, all of which ended up in /usr/share/java as far as I can make out. With a completely basic config, activemq started up fine, but as soon as I added any authentication or authorization sections to my config, it barfed with a NoClassDefFound error for org.objectweb.asm.commons.EmptyVisitor
. This class is definitely provided by /usr/share/java/asm3-all.jar, which is happily installed on my system presumably as a result of the dependencies specified in the activemq package.
So what gives? After a fair bit more digging, it turns out that most of the jars required to operate activemq are also installed directly in /usr/share/activemq/lib
- including asm3.jar, but, crucially, not asm3-all.jar, which includes the offending class. As an experiment, I copied the jar from /usr/share/java/ to the activemq lib directory... and it all worked fine.
So my question is: why on earth did the activemq package install 150+MB of jars in /usr/share/java if it actually doesn't use any of them??? In my days as a Java programmer I would have assumed that an java app would just have to bundle all of its dependencies and be done with it, but the fact that activemq pulls in all these libraries as dependent packages seems to suggest that someone thinks otherwise... or is this just a balls up?
This is something that I think I'll start calling the "Linux Effect" on Java. When you use the package installer for Java and Java-based apps, the apps are installed according to general Linux standards: /etc for config, /usr for binaries, /bin for executables, etc. It scatters the bits around to such an extent that I've never made the leap to understanding how it's all organized. As a Java developer working with both RHEL and Ubuntu myself, I never use the package installer for any JDK or Java app--especially since then I'd have to remember where things are in two distros. As you said, most Java apps are a simple "download and extract to..." away to get them running. Then it's all in one place, and there's no question about where to look for things.
The answer to how this is supposed to work is now a bit clearer to me after some digging. The activemq package depends on
libactivemq-java
, which is the package that installs everything in /usr/share/java. All theactivemq
package itself does is to set up a series of symlinks into /usr/share/java from its own lib directory. So the dependencies are used, it's just that in the case the package maintainer has failed to link in one of the jars that's actually necessary (I will report this as a bug). It would seem that the intention (for better or worse) is that java libraries get installed centrally through the package management system and linked to by the application as required using symlinks.