Sunday, April 26, 2015

"ArtifactTransferException: Failure to transfer com.sun.jmx:jmxri:jar:1.2.1", How to resolved this Maven Error?

While I was creating a maven module for my project, I noticed an Error Message in my Eclipse Problem window or when you open the POM.xml and see the Red “X” and it shows:

Multiple annotations found at this line:
                - ArtifactTransferException: Failure to transfer com.sun.jmx:jmxri:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, 
                 resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced. Original error: Could not transfer artifact com.sun.jmx:jmxri:jar:1.2.1 from/to 
                 java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type 
                 legacy using the available factories AetherRepositoryConnectorFactory, WagonRepositoryConnectorFactory
                - ArtifactTransferException: Failure to transfer com.sun.jdmk:jmxtools:jar:1.2.1 from https://maven-repository.dev.java.net/nonav/repository was cached in the local repository, 
                 resolution will not be reattempted until the update interval of java.net has elapsed or updates are forced. Original error: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to 
                 java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type 
                 legacy using the available factories AetherRepositoryConnectorFactory, WagonRepositoryConnectorFactory
                - Missing artifact com.sun.jdmk:jmxtools:jar:1.2.1
                - Missing artifact com.sun.jmx:jmxri:jar:1.2.1

To cut the story short, this was caused when I added the log4j 1.2.15 in my pom.xml as shown below:

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

To fix the problem, I excluded the jdmk.jmxtools, jmxri and jms by using following code snippet for my log4j 1.2.15 dependency:

      <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
                  <exclusions>
                        <exclusion>
                              <groupId>com.sun.jdmk</groupId>
                              <artifactId>jmxtools</artifactId>
                        </exclusion>
                        <exclusion>
                              <groupId>com.sun.jmx</groupId>
                              <artifactId>jmxri</artifactId>
                        </exclusion>
                        <exclusion>
                              <groupId>javax.jms</groupId>
                              <artifactId>jms</artifactId>
                        </exclusion>
                  </exclusions>
      </dependency>

No comments: