| 24 February 2010 |
I knew I solved this problem earlier: I just didn't know how I solved it. That's just why wiki's and blogs are invented.
The problem? One of the developers we're currently coaching was getting started with the Mule ESB using the book Mule in Action .
When trying to run the Maven-based samples that came with the book, Maven wasn't able to find the com.sun.jmx:jmxri:1.2.1 and com.sun.jdmk:jmxtools:jar:1.2.1 dependency. Looking at our internal repository, only the related pom.xml appeared to be there (and not the jar).
Investigating the dependencies of the samples, there was no direct dependency. So, it had to be an indirect dependency. Then it struck me: log4j ! The latest version (1.2.15) depends on these com.sun.jmx packages and you won't be needing them for average logging scenario's.
The solution is kinda pragmatic, but hey ... it works! Look at your pom.xml, find the log4j dependency. Now, you have two options:
- If you depend on the latest version you have to exclude the following dependencies:
XML:
-
<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>
-
</exclusions>
-
</dependency>
-
- If no version is mentioned, add the version number:
XML:
-
<dependency>
-
<groupId>log4j</groupId>
-
<artifactId>log4j</artifactId>
-
<version>1.2.14</version>
-
</dependency>
-
Note: If you do need the com.sun.jmx dependencies. Download the libraries from the Sun Oracle website and upload them to your Maven repository.
Disclaimer: you already noticed, but this solution only works if you have a direct dependency to log4j. Generic advice would be to find out if any indirect dependency exists and exlude it in your pom.xml.

