Manasvi Gupta bio photo

Manasvi Gupta

Apache Kafka, Spark, Scala

Twitter LinkedIn Github

If you have used log4j 1.2 on your project via Maven, you may have see missng artifact error for following Sun jars - com.sun.jmx:jmxri, com.sun.jdmk:jmxtools and javax.jms:jms.


Common solution to this problem is to exclude these dependencies, as suggested on Stackoverflow.

<!-- update your pom.xml to exclude sun jars -->
<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>


But, what if you actually need these jars available locally in maven repository ? For e.g. I needed Sun jars for compiling and debugging log4j source code. You can read more about it here.

Handling missing com.sun.jmx:jmxri, com.sun.jdmk:jmxtools

Download these jars from Oracle site and install manually in m2 repository using following commands -

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

Handling missing javax.jms:jms