Quantcast
Channel: Crunchify
Viewing all articles
Browse latest Browse all 1037

How to Fix Maven Artifacts Could not be Resolved Error? Exclude jms, jmxri & jmxtools JAR Dependencies

$
0
0

I remember long time ago, I faced the same error and I tried fixing it by manually adding .jar files to my maven repository locally.

I executed below command to install it in my localhost maven repo and everything worked.

#echo "installing jmxri 1.2.1"
mvn install:install-file -Dfile=lib/jmxri-1.2.1.jar -DgroupId=com.sun.jmx -DartifactId=jmxri -Dversion=1.2.1 -Dpackaging=jar

#echo "installing jmxtools 1.2.1"
mvn install:install-file -Dfile=lib/jmxtools-1.2.1.jar -DgroupId=com.sun.jdmk -DartifactId=jmxtools -Dversion=1.2.1 -Dpackaging=jar

#echo "installing jms 1.1"
mvn install:install-file -Dfile=lib/jms-1.1.jar -DgroupId=javax.jms -DartifactId=jms -Dversion=1.1 -Dpackaging=jar

Jar files will be installed at provided location once you execute above command:

But I didn’t try to fix this permanently. Recently I changed my laptop and again I started seeing the issue as seen below as all my manually inserted jar files were gone.

The following artifacts could not be resolved: javax.jms:jms:jar:1.1, 
com.sun.jdmk:jmxtools:jar:1.2.1, 
com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net 
(https://maven-repository.dev.java.net/nonav/repository): Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available connector factories: BasicRepositoryConnectorFactory: 
Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available layout factories: Maven2RepositoryLayoutFactory: Unsupported repository layout legacy -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project crunchify-tutorial: 
Could not resolve dependencies for project crunchify.com.tutorial:crunchify-tutorial:jar:1.0.0-SNAPSHOT: 
The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, 
com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): 
Cannot access https://maven-repository.dev.java.net/nonav/repository with type legacy using the available connector factories: BasicRepositoryConnectorFactory

After digging further I found that, in my Java Project I was using 1.2.15 log4j dependencies.

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

By default log4j 1.2.15 version adds all above 3 dependencies. Same for zookeeper 3.3.2 version.

How to fix this this permanently?

There are two options.

Option-1.

Just upgrade log4j and zookeeper to latest version. log4j 1.2.16 and zookeeper 3.4.9 doesn’t have these dependencies.

Option-2.

Add below exclusions code to your project’s pom.xml file.

Here is a code:

<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>

Let me know if you still face any issue.

Have a suggestion on article? Please chime in and share it as a comment.

The post How to Fix Maven Artifacts Could not be Resolved Error? Exclude jms, jmxri & jmxtools JAR Dependencies appeared first on Crunchify.

Author: App Shah

Crunchify, LLC Logo


Viewing all articles
Browse latest Browse all 1037

Trending Articles