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.
March 5, 2008 at 8:47 am |
This solved my problem, thanks for taking the time to post this.
March 5, 2008 at 10:50 am |
You’re welcome. And suddenly, it was worth it.
March 11, 2008 at 10:51 am |
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.
March 24, 2008 at 11:18 am |
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:
log4j
log4j
1.2.15
javax.jms
jms
com.sun.jdmk
jmxtools
com.sun.jmx
jmxri
April 3, 2008 at 6:45 am |
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,
April 3, 2008 at 6:50 am |
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
April 5, 2008 at 5:45 pm |
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
April 5, 2008 at 5:51 pm |
Sorry, I guess I should have realized that this blog is stripping tags. How about this:
gt;
gt;log4jgt;
gt;log4jgt;
gt;1.2.15gt;
gt;
gt;
gt;com.sun.jmxgt;
gt;jmxrigt;
gt;
gt;
gt;com.sun.jdmkgt;
gt;jmxtoolsgt;
gt;
gt;
gt;javax.jmsgt;
gt;jmsgt;
gt;
gt;
gt;
May 6, 2008 at 9:30 am |
[...] post expands on this post from One Man Went to Mow… to add the jms and mail [...]
June 4, 2008 at 9:49 am |
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.
August 1, 2008 at 2:17 am |
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!
August 7, 2008 at 6:18 am |
Exclude it in your pom file if you do not need it, e.g.
log4j
log4j
1.2.15
com.sun.jdmk
jmxtools
com.sun.jmx
jmxri
August 18, 2008 at 2:31 pm |
Excellent posts guys… but the question is… why in the world would the log4j depend on the jmxtools and jmxri files?
September 9, 2008 at 3:52 am |
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
October 13, 2008 at 12:30 pm |
I also ran into this problem. I also dropped the version back to 1.2.14 and maven built fine.
Good tip from Rolf.
January 24, 2009 at 12:47 am |
[...] 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 [...]
April 14, 2009 at 7:17 am |
[...] One Man went to Mow [...]
May 18, 2009 at 10:44 am |
[...] 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 [...]
May 25, 2009 at 5:55 am |
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