Category: Maven Gene De Lisa @ 6:31 am —
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

For some reason log4j 1.2.15 has a compile time dependency on JMX even if you’re not going to compile log4j. Go figure. I’m not the first one to point this out since there is a bug report issued.

What’s worse is that the jars are not in any maven repository due to Sun licensing restrictions. So what do you do? There are two things you can do.

  • Install them to your local repository.
  • Say no thanks

To install the jars to your local repository:

Get the jars from Sun. Download the “JMX 1.2.1 Reference Implementation”.

Then rename them to include the version.

copy jmxtools.jar jmxtools-1.2.1.jar
copy jmxri.jar jmxri-1.2.1.jar

Then install them to your local repo:

mvn install:install-file -DgroupId=com.sun.jdmk -DartifactId=jmxtools -Dversion=1.2.1 -Dpackaging=jar -Dfile=jmxtools-1.2.1.jar
mvn install:install-file -DgroupId=com.sun.jmx  -DartifactId=jmxri    -Dversion=1.2.1 -Dpackaging=jar -Dfile=jmxri-1.2.1.jar

If you also need JMS download them from Sun too.

To say “No thanks”:

You can see the log4j build dependencies at their site. Here they are.

GroupId ArtifactId Version
com.sun.jmx jmxri 1.2.1
com.sun.jdmk jmxtools 1.2.1
javax.jms jms 1.1
javax.mail mail 1.4

So, you can just say “I don’t want them” by excluding them.

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>

<exclusions>

<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>

<exclusion>
<groupId>com.sun.jdmk</groupId>
<artifactId>jmxtools</artifactId>
</exclusion>

<exclusion>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
</exclusion>

</exclusions>
</dependency>

Sorry, no comments yet.

Write Your Comment

Comment Guidelines: Basic XHTML is allowed (a href, strong, em, code). All line breaks and paragraphs will be generated automatically.

You should have a name, right? 
Your email address, I promised I won't tell it to anyone. 
If you have a web site or blog, you can type the URL right here. 
This is where you type your comments. 
Remember my information for the next time I visit.