maven and log4j
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.
1 2 |
copy jmxtools.jar jmxtools-1.2.1.jar copy jmxri.jar jmxri-1.2.1.jar |
Then install them to your local repo:
1 2 |
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 | 1.4 |
So, you can just say “I don’t want them” by excluding them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<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> |
Thanks for taking the time to post saved me the time