Missing artifact Maven

In maven, missing artifact error in pom.xml is due to dependency download problem. The error in pom.xml “missing artifact maven” occurs when the artifact is missing in local repository and remote repository. In eclipse, missing artifact maven error shows in the programs window.

Maven is a software tool for building artifacts. The maven exception “Missing artifact” is thrown when a new dependency is added in the pom.xml file. A maven dependency is identified with group Id, artifact Id and version. If there is a problem related to these parameters, the exception “Missing artifact” will be thrown from maven pom.xml.

The code below displays an error message “Missing artifact Maven” due to dependency problem. In eclipse, along with this exception, additional errors will be shown in the programs window.

Missing artifact org.apache.commons:commons-lang3:jar:3.9.1
The container 'Maven Dependencies' references non existing library '../../.m2/repository/org/apache/commons/commons-lang3/3.9.1/commons-lang3-3.9.1.jar'
The project cannot be built until build path errors are resolved

Root Cause

The exception “missing artifact maven” can occur if a new dependency is added in the pom.xml file. Maven will check the dependence of the local repository. If this is not available, try downloading it from the source url. If the dependency is not present in either local repository or remote repository, this exception will be thrown.

There might be a different reason not to find the dependent jar files. Maven distinguishes dependency based on three factors, group id, artifact id and version.

Solution 1

Check the group id and artifact id in the dependency configuration in pom.xml. If this is a spelling error, correct it and refresh. This exception will be resolved. Make sure that the group id and artifact id are correct in the pom.xml file. The artifact like jar file is located using these parameters.


Solution 2

For this exception, the version is an important factor. The jars are placed in a path that is based on group id and artifact id. There are several jars available for a dependency based on their versions. For example, the jar file is going to have different versions. The jar is added to the project on the basis of the version specified in pom.xml.

First, make sure that the version number is correct. Check whether the file is available in the local repository or not. Check the version in the downloadable link on the internet.

Solution 3

Check the jar file in your local repository. The version folder is sometimes created in the local repository, but the jar file is missing. This will happen if the internet is disconnected while downloading or if something happens while downloading the jar file. In this case, there will be a folder in the local repository. But the jar file is not going to be available.

Download the jar file from the internet and place the jar file in your local repository folder.

Solution 4

This solution is not recommended at all times. If you are not concerned about your.m2 local repository, delete the local repository and refresh the maven project. Maven is going to try to download all the jars from scratch. If there is a repository related issue, this step will resolve the exception “missing artifact maven”.

Note that this will also affect other maven projects as you delete a complete.m2 local repository. It is recommended that you take backup of the entire.m2 local repository.

Solution 5

If you use eclipse as your IDE, recompile the entire project. Click “Project->clean” in the menu. This will clean up all of the target and bin folders. If there is any issue in the folder structure of the maven project, this step will resolve the issue. If any file is locked in the target or bin folders, fix it first. From the menu, click “Project->clean.”

Run the maven after cleaning the project build directory. This step is going to solve the exception.

Solution 6

In the maven project, right-click the name of the project, click “Maven->Update Project.” If any problems occur while downloading or linking the jar to the maven project, they will be resolved in this step. Maven is trying to check all the dependency jar links with the local repository and remote repository. In this step, if any issues related to linking jars will be resolved. The maven error missing artifact will also resolved.

Solution 7

If none of the above steps is working, then try these steps to resolve missing artifact maven error in pom.xml

  • try to close the project and open up the project
  • try to close the eclipse and begin the eclipse again
  • try to shut down your system and restart your system.

Leave a Reply

Your email address will not be published. Required fields are marked *