Aug 26 2009

Maven, Log4j and javax.jms

Published by michael at 8:37 am under Java, Logging, Maven

Log4j version 1.2.15 added features which has new dependencies on sun and javax packages. When you try to build your project using Maven and log4j 1.2.15 you will see this:

[INFO] Unable to find resource 'com.sun.jmx:jmxri:jar:1.2.1' in repository central (http://repo1.maven.org/maven2)
[INFO] Unable to find resource 'com.sun.jdmk:jmxtools:jar:1.2.1' in repository central (http://repo1.maven.org/maven2)
[INFO] Unable to find resource 'javax.jms:jms:jar:1.1' in repository central (http://repo1.maven.org/maven2)

These packages are not in the Maven repositories due to licensing issues. There are two simple solutions to this problem. You can either modify your pom.xml file to use the previous version of log4j (log4j 1.2.14) which doesn’t depend on the JMX and JMS packages:

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

Or you can exclude the dependencies with the caveat that some of the lo4gj appendersĀ  that depend on these packages wont be available

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.15</version>
    <exclusions>
        <!--
        These packages are not in the Maven repository
        If you do this certain log4j appenders will not be available
        -->
        <exclusion>
            <groupId>javax.jms</groupId>
            <artifactId>jms</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.sun.jdmk</groupId>
            <artifactId>jmxtools</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.sun.jmx</groupId>
            <artifactId>jmxri</artifactId>
        </exclusion>
    </exclusions>
</dependency>
Share and Enjoy:
  • Print
  • Sphinn
  • del.icio.us
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Technorati
  • Twitter

Related posts:

  1. Want to use Spring 3.0 milestone release from Maven? I wanted to add the Spring 3.0 M4 milestone early...
  2. How to find project dependencies in a Maven project It’s very useful to be able to see what...
  3. Maven pom.xml structure I wanted to see the full Maven pom.xml structure and...

No responses yet

Trackback URI | Comments RSS

Leave a Reply