Resolving java jar dependencies

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

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.

Читайте также:  Python framework for api

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

How to fix this this permanently?

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:

  com.sun.jmx jmxri  com.sun.jdmk jmxtools  javax.jms jms   

Let me know if you still face any issue.

If you liked this article, then please share it on social media. Have a question or suggestion? Please leave a comment to start the discussion.

Suggested Articles.

Give me a try.

About App Shah

I’m an Engineer by profession, Blogger by passion & Founder of Crunchify, LLC, the largest free blogging & technical resource site for beginners. Love SEO, SaaS, #webperf, WordPress, Java. With over 16 millions+ pageviews/month, Crunchify has changed the life of over thousands of individual around the globe teaching Java & Web Tech for FREE.

Subscribe To Newsletter…

Stay up to date & never miss an update! Signup for news, latest articles and special offers!! Join 16+ million monthly readers. 👋

You can unsubscribe at any time.

Источник

Оцените статью