Aarg! What a nightmare. I finally — fine, call me stupid — figured out where to/how to get the JMX dependencies for Log4J.
I am using Commons Logging, which in turn, likes to use Log4J. So, I added this to my Maven project file (pom.xml):
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
However, log4j has a dependency on jmx, which maven dutifully brings to my attention.
And this is where it gets interesting, the Maven repositories all have a pom for these but NOT the jar’s.
It turns out you need to download the jars from Sun’s Download site (which you have to register for). (To navigate there, go to http://www.sun.com/download, then search the download center for JMX, then select the Java Management Extensions Download Information, then select the JMX 1.2.1 Reference Implementation,then select the JMX RI 1.2.1 download. Whew!)
After downloading, you need to rename the jars from jmx*.jar
to jmx*-1.2.1.jar
. Then you can register them with Maven (I use Artifactory, which made this a lot easier.) Be sure to change the GroupId as follows:
com.sun.jdmk:jmxtools
com.sun.jmx:jmxri
With the jars in the repository, the JMX dependencies now resolve properly.
This solved my problem, thanks for taking the time to post this.
You’re welcome. And suddenly, it was worth it.
Kudos on this post. I ran into a similar problem and was getting really frustrated.
While the instructions above described two of the dependencies I was missing I was still having trouble downloading jms-1.1.jar as it looks like Sun is about to release a new product which supersedes it. I ended up just doing an explicit Google search for jms-1.1.jar, found it, installed it and now I’m up and running again.
Thanks again. 🙂
But one question is still unanswered: do we really need jmx or jms now to use log4j in any case? I belive not! So I gracefully exclude those dependencies in my master pom:
I agree with Mathias.
Those files are not required if your program doesn’t make use of JMS or JMX.
Excluding them as dependency is the best way to deal with this problem.
The dependency that Maven detects, are required for buidling the Log4J libraries.
Here a example of excluding all indirect dependencies for Log4J in your pom.xml file:
log4j
log4j
1.2.15
compile
com.sun.jdmk
jmxtools
com.sun.jmx
jmxri
javax.jms
jms
javax.mail
mail
javax.activation
activation
Be sure that you don’t need them !
Kind regards,
Excuse me, some how my paste action has failed.
The right content of the pom.xml file should be:
log4j
log4j
1.2.15
compile
com.sun.jdmk
jmxtools
com.sun.jmx
jmxri
javax.jms
jms
javax.mail
mail
javax.activation
activation
I agree, excluding is the way to go. To exclude, enter the following in your pom.xml
log4j
log4j
1.2.15
com.sun.jmx
jmxri
com.sun.jdmk
jmxtools
javax.jms
jms
Sorry, I guess I should have realized that this blog is stripping tags. How about this:
[…] post expands on this post from One Man Went to Mow… to add the jms and mail […]
Thx for the details. I got the Log4J working now. Finding out the JMS and JMX took time, thx to Google for showing them on mouse click.
There is another easy way to get rid of the dependencies: Simply use the previous version of Log4j. Change the version number to 1.2.14 and you can cut out all the exclusions from your pom.xml!
Exclude it in your pom file if you do not need it, e.g.
Excellent posts guys… but the question is… why in the world would the log4j depend on the jmxtools and jmxri files?
Hi, thanks for featuring this topic, it got me stuck for a while, too. I’ve just come out with another solution which doesn’t require excluding or installing anything manually. The Maven2 repository on JBoss contains the needed artifacts, just add the following repository to your Maven2 settings and Maven will find those: http://repository.jboss.com/maven2
I also ran into this problem. I also dropped the version back to 1.2.14 and maven built fine.
Good tip from Rolf.
[…] sometimes, with the xml, with some weird repositories publishing strange versions, or just with Log4J for example, depending on libraries not available on any repository, but hey, Maven downloaded for […]
[…] One Man went to Mow […]
[…] could download and install these artifacts to the local repository, if we really needed them. But in most cases, they’re not needed and thus you won’t […]
Hey,
I was just following the same problem. I found this link which might be of help:
http://www.nabble.com/newbie:-why-does-log4j-pull-down-all-sorts-of-files–td21821665.html
it mentions 2 repositories which may have the extra jars:
http://download.java.net/maven/2/
http://repository.jboss.org/maven2/
Also talks about using transitive=”false” which should stop it downloading all the other deps.
hope this is of use.
Jim
Use 1.2.13 of log4j. These are new dependencies in 15.
Thank you! I was also wasting the day with this stupid error!
Thanks Demian, that’s handy and it works. Just replaced the [ and ].
Thanks a lot. I saved a lot of time because of you. Thank you
Now that Oracle has assimilated Sun, where are we supposed to get these JMX management extensions? Its impossible to find things on Oracle’s site now.
Found them:
http://java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/download.jsp
[…] leave a comment » Aarg! What a nightmare. I finally — fine, call me stupid — figured out where to/how to get the JMX dependencies for Log4J. I am using Commons Logging, which in turn, likes to use Log4J. So, I added this to my Maven project file (pom.xml): <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> </dependency> However, log4j has a dependency on jmx, whi … Read More […]
A better solution would be to get other people to start hosting the JAR from their own Maven repositories. Having to manually fetch any dependency from anywhere largely defeats the purpose of using Maven in the first place.
[…] post expands on this post from One Man Went to Mow… to add the jms and mail […]
Spot on with this writeup, I actually believe this website needs a great deal more attention. Ill probably be returning to read through more, thanks for the info! dadcbedgaddk
[…] Fifth, start a technical blog. As you learn a new skill, you will explore technologies and will probably have to “figure stuff out”. When you do, blog about it. I still get hits on one of the technical articles that I wrote years ago about a weird problem with Maven. […]