342

I am hoping someone can help me with a problem I am struggling with.

When I try to build my project from the terminal I get this error:

Failed to read artifact descriptor for com.morrislgn.merchandising.common:test-data-utils:jar:0.3b-SNAPSHOT: Could not find artifact com.morrislgn.merchandising:merchandising:pom:0.3b-SNAPSHOT

The common.test-data-utils jar is created by a separate project and shared between this and another project (the other project doesn't build either, but that is down to another problem).

I am able to build com.morrislgn.merchandising.common:test-data-utils without issue, I can see the entry it makes in the .m2 local repository on my machine. I have reindexed my repository in Eclipse also.

The POM for my project has this entry:

<dependency>
    <groupId>com.morrislgn.merchandising.common</groupId>
    <artifactId>test-data-utils</artifactId>
    <version>0.3b-SNAPSHOT</version>
</dependency>

Which appears to be correct to me - the POM doesn't report any errors either when it is viewed in Eclipse.

Can some one tell me what I am missing here or doing wrong?

3
  • 6
    If someone (like me) encounters this error due to http repository in maven > 3.8.1, something like maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories:, refer this: www.greatytc.com/q/67001968/6346531
    – aksh1618
    Commented Jun 16, 2021 at 11:56
  • @aksh1618 Thanks. That was the resolution for my issue
    – Shreehari
    Commented Nov 17, 2021 at 5:11
  • I just commented the default mirror section and all dependencies were downloaded then..
    – Nesquik27
    Commented Feb 26, 2024 at 1:14

25 Answers 25

225

You can always try mvn -U clean install

-U forces a check for updated releases and snapshots on remote repositories.

5
  • 51
    @MrPhi: If you have the m2e plugin, then you can use Maven -> "Update Project...". The next dialog will have an option to force updates of snapshots and releases. Commented Mar 13, 2014 at 14:04
  • 1
    @AaronDigulla It's that dialog box which is causing the error for me.
    – Jeroen
    Commented Apr 13, 2014 at 21:15
  • 2
    To make this works you should run command being inside of root dir of your project
    – Daria
    Commented Mar 14, 2016 at 17:44
  • 2
    I had a similar issue as well. This really helps, and in addition, if you are using private mvn repo, make sure to add that to your ~/.m2/setting.xml mirror section first, and then after running mvn -U clean install, make sure to Reimport (right click the project, then under the bottom Maven section there is a Reimport button).
    – JACK ZHANG
    Commented Apr 3, 2018 at 0:45
  • 1
    @TomaszWaszczyk : Yes there is. 1. Windows-show view->Terminal. 2. Add local terminal 3. cd PomFilePath 4. Run the command Commented Apr 22, 2019 at 4:59
188

This problem can occur if you have some child projects that refer to a parent pom and you have not installed from the parent pom directory (run mvn install from the parent directory). One of the child projects may depend on a sibling project and when it goes to read the pom of the sibling, it will fail with the error mentioned in the question unless you have installed from the parent pom directory at least once.

I just ran into this problem when moving a project to a new computer. I was in the habit of running commands from the child project and didn't run install on the parent.

6
  • 18
    In addition, when running mvn install on parent you can also add -N for non-recursive operation. This will cause maven to skip all the modules (including one that fails) and just do install goal for the parent. Commented Oct 7, 2015 at 16:02
  • @JacekPrucia good to know that a pom artifact also needs to be installed (if your parent is a pom)
    – Adrian
    Commented Dec 16, 2016 at 0:39
  • @bzuillsmith why would you need to run mvn install in the parent pom. Wouldn't this only be used so the sibling dependency can be downloaded? If you happen to have went to the sibling directory & ran mvn install from there so that the jar is in your local repository, doesn't this accomplish the same exact thing? Commented Nov 7, 2017 at 16:45
  • 1
    It's been a few years since I've used maven, but--Yes, I believe you can install the sibling dependencies one by one. Installing from the parent just tends to be less work (fewer commands to type and run). There may be cases in large projects where you don't want all child projects installed in which case you would need to run them individually. Commented Nov 13, 2017 at 4:59
  • My project like ch-multip-spring\simple-parent\simple-model\pom.xml, I do mvn clean install from root ch-multip-spring folder(not from simple-parent as well), it solved my the issue similar to the post title.
    – IcyBrk
    Commented Jan 13, 2018 at 15:02
144

Had the same issue with IntelliJ IDEA and following worked.

  • Go to File
  • Select Settings
  • Select Build, Execution, Deployments
  • Select Build Tools from drop down
  • Select Maven from drop down
  • Tick the Always update snapshots check box

screen shot of IntelliJ 2017.2 > Preferences/Settings > Build, Execution, Deployment > Build Tools > Maven > Always update snapshots (checkbox)

3
  • 1
    This worked for me, but I don't understand why - I was attempting to build from the command line. Was there something cached from IntelliJ?
    – SML
    Commented Jan 25, 2018 at 1:07
  • 1
    @ goodOldFashioned: This "always update" overwrote the ....lastUpdated file from the local repository. -U does the same from the commandline. So intellij fixed your local repo, and then the commandline worked again.
    – Frischling
    Commented Sep 5, 2018 at 7:32
  • 3
    after browsing the whole internet, finally this worked for me
    – khawarizmi
    Commented Feb 11, 2019 at 14:12
59

If you are using Eclipse, Right Click on your Project -> Maven -> Update Project. It will open Update Maven Project dialog box.

In that dialog box, check Force Update of Snapshots/Releases checkbox & click OK. (Please refer image below)

Update Maven Project Dialog Box

This worked for me !

0
40

If you're using Eclipse:

  • Right click on project > Properties > Maven

  • Make sure that Resolve dependencies from workspace projects is not clicked.

2
  • 4
    It works for me. But I dont understand why? Any explanation behind this?
    – Anand
    Commented Nov 13, 2017 at 7:26
  • 1
    this did not work for me, initially 12 decencies were missing, after doing this it is 74 now Commented Aug 22, 2018 at 14:17
29

I know I'm pretty late to the conversation, but I had this problem too. I think the issue was my company's firewall. My solution was to unplug from the network, connect to our open wireless and then force an update via Eclipse. This resolved everything.

1
15

I had the same issue with eclipse where the maven build command line worked just fine BUT try this

  • go into .m2/repository and wipe the directory associated
  • run update maven dependencies in eclipse

The error goes away....why my mvn command line worked with those directories and eclipse .m2eclipse could not, I have no idea and it kinda sucks. My project is now working in eclipse again.

2
  • on a side note, we switched to gradle....so much happier than ant and maven....extremely nice setup. Commented May 8, 2013 at 19:57
  • Not even sure it's anything Eclipse-related. I had the same issue with IntelliJ and deleting the problematic packages and re-running mvn clean install worked
    – Jay
    Commented Jul 19, 2017 at 23:41
14

I had same problem using IntelliJ. I solved with right click on pom.xml > Maven > Reimport

0
12

I solved this issue by deleting in the repository folders where this error was shown everything except the .jar and .pom files.

1
  • I have also solved the same issue by deleting related files in the maven local repository and then update the whole project. Commented Dec 9, 2016 at 11:37
9

For me , it was related to setting the "User Setting.xml" inside

Window > preferences > Maven > User Settings > and then browsing to the user Settings inside the { maven unarchived directory / }/apache-maven-2.2.1/conf/settings.xml . 
0
8

"Failed to read artifact descriptor" problems generally indicate a problem with the dependency's pom file in the maven repository. I would suggest you to double check if the pom file's name is the same with the name maven expects, and also to check if the pom file contents are valid.

1
  • 1
    The check of the pom.xml was useful. I found I had same dependency twice (copy & paste error). After cleanup everything was fine. Commented Mar 8, 2016 at 8:21
8

Navigate via shell inside of your project folder and run following command:

mvn -U clean install

Usually this should already solve your problem.

If you see a message like this:

Could not resolve dependencies for project :war:0.0.1-SNAPSHOT: Failed to collect dependencies at com.sun.jersey:jersey-server:jar:1.9

Then execute:

export MAVEN_OPTS=-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2

followed by:

mvn -U clean install

again to finally update your dependencies.

Afterwards perform clean maven build:

maven clean install
7

I have a project

 A/
 |--a1
 |--a2

Now there is another project in our org

 B/
 |--b1
 |--b2
 |--b3

(Every module a1, b1 etc. and Parent projects A, B have their own pom.xml as per standard maven rules of parent and child)

Both projects are checked out on my local eclipse (from SVN). I am actively working on A.

I came to know that there is a good common functionality (b4) developed in B and I needed to use it.

 B/
 |--b1
 |--b2
 |--b3
 |--b4 (NEW)

Developer of b4 have deployed this b4 module as an artifact in our org's repository. I included the dependancy to my module's POM i.e. a2's pom.xml. Eclipse downloaded the reuqired artifact from repo and I could import the classes in it.

Now issue starts... I needed to check the source code of b4 for some purpose and as I already had B checked out on my local eclipse I updated it from SVN and checked out module b4. I also ran pom.xml of module b4 with targets like clean, package etc. After some time when I finishedd my coding I needed to create a JAR of my module a2. I ran "package" on a2's pom.xml and BAM!! errors n errors for a2 module.. These errors were also not very user friendly. Only thing is there was b4's name for sure in logs.

Solution: After trying for many solutions for many hours, I ran "mvn -U clean install" from console in my B's project directoty (i.e. in ../codebase/B). As B is the parent, clean install command ran for all modules including b4 and it ran successfully. After this I ran "mvn -U clean install" for my parent project which is A. And this worked! a2 module got compiled, installed, (packaged later) succesfully.

Here important point was if b4 is in your workspace do not only install b4. You will need to clean-install complete B. I came up to this solution after reading answer from Zuill

EDIT: One more thing here to note that if I didn't had B project checked out in Local environment then this issue might not have occurred for me. I tend to think that this happened cause I had B checked out in my local workspace.

1
  • Thanks for your help. I meet the same problem, project A add a dependency from project B's submodule B-IDL. I should mvn deploy whole B project, not just mvn deploy submodule B-IDL. Commented Dec 4, 2021 at 5:49
5

You mention two different groupIds, com.morrislgn.merchandising.common and com.johnlewis.jec.webpim.common. Maybe this is the problem.

1
  • Good spot - no, its not unfortunatly. I copied the wrong tag from the POM XML, that was the one above the tag I needed and didnt spot what I'd done. Ooops! I've edited the question to fix my stupidity!
    – Morrislgn
    Commented Jul 10, 2011 at 20:42
5

I had the same problem for a while and despite doing mvn -U clean install the problem was not getting solved!

I finally solved the problem by deleting the whole .m2 folder and then restarted my IDE and the problem was gone!

So sometimes the problem would rise because of some incompatibilities or problems in your local maven repository.

1
  • Tried doing a Maven resync while offline, and completely hosed IntelliJ. Followed your advice, deleted .m2, and now it's working like a charm! Thanks! Commented Jun 14, 2017 at 0:33
5

For me, it seems to actually have been a problem with the dependency POM.

I worked around it by using the jitpack virtual repository, with which you can include github repositories based on their URL instead of their own POM (which seems to have been erroneous in my case).

<repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
</repository>
1
  • This worked for me. The repository section of the pom.xml file should be properly updated and the </id> tag should be the name of the repository. Saved a lot of my time! Commented Sep 1, 2020 at 8:07
4

Reference Maven error "Failure to transfer..."

find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
3

In our case the error appeared because of the incorrect groupId renaming while some of the projects in multi-module Maven configuration references to others.

We had an aggregator project (billing-parent) with two modules (billing-api, billing):

com.company.team:billing-parent
|-com.company.team:billing-api
|-com.company.team:billing

Project billing depends on billing-api. So in its pom.xml it had:

<dependency>
    <groupId>com.company.team</groupId>
    <artifactId>billing-api</artifactId>
    <version>${project.version}</version>
</dependency>

We decided to rename groupId from com.company.team to com.company.team.billing. We replaced old value in parent's pom.xml and in <parent> sections of both modules. But forgot to update dependency above. So we had got configuration in which billing project references old billing-api artifact. Eventually it beaks build of the billing module after some time with the error like

[ERROR] Failed to execute goal on project billing: Could not resolve dependencies for project com.company.team.billing:billing:jar:3.5.1-SNAPSHOT: Failed to collect dependencies at com.company.team:billing-api:jar:3.5.1-SNAPSHOT: Failed to read artifact descriptor for com.company.team:billing-api:jar:3.5.1-SNAPSHOT: Failure to find <parent of the com.company.team:billing-parent project which is not available any more>

despite the fact that billing-api module builds without errors.

Solution 1: rename groupId in dependency as well.

Solution 2: replace groupId by the ${project.groupId} property like this:

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>billing-api</artifactId>
    <version>${project.version}</version>
</dependency>

Conclusion. So my advice in case you encountered with the error in multi-module configuration whould be: thoroughly check groupId and artifactId of the dependencies on neighbour modules.

3

I know I'm brave, nine years after the question...

For me it was a problem where sub-dependencies weren't found. I finally found the real issue by looking at the "Error Log"-view that held a An internal error occurred during: "Building".-line. Double-clicking it showed a pop-up with a stacktrace and the last cause finally disclosed a broken JAR in my local repository. I cleaned that up and Eclipse/m2e was able to work again.

0
1

I had a similar problem. In my case, the version of testng in my .m2/repositories folder was corrupt, but when I deleted it & did a maven update again, everything worked fine.

1

This error is basically saying that maven couldn't read a certain dependency from local repository. It might happend because a jar file didn't get downloaded correctly. So, go to your maven local repository and make sure there isn't any .lastUpdated extension file.

1
  • This was my issue. Once I deleted the lastUpdated file for the dependency which was failing it worked fine. Commented Jul 10, 2020 at 9:10
1

I'll answer this question because it is the first one goggle finds. In my case, root cause was hidden in the stack trace of the problem:

    Failed to read artifact descriptor for jakarta.activation:jakarta.activation-api:jar:1.2.2
    at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
    ...
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: jakarta.activation:jakarta.activation-api:pom:1.2.2 failed to transfer from https://nexus.akbankpreprod.com/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of maven-public has elapsed or updates are forced. Original error: Could not transfer artifact jakarta.activation:jakarta.activation-api:pom:1.2.2 from/to maven-public (https://nexus.akbankpreprod.com/repository/maven-public/): PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

"Original error" section says I need to add my nexus server's sercurity certificate to jre trust store.

1
  • Same problem for me. I reran with -X and saw a PKIX cert error.
    – brt
    Commented Oct 7, 2024 at 15:05
0

I had this problem in eclipse, mvn -U clean install didn't work but right clicking the project and selecting Maven->Update Project fixed it.

0

I just started using STS Eclipse with first time using Maven. The project I setup already had its own settings.xml. If this is the case, you'll want to update your settings.xml file in run configuration.

  1. right click the pom.xml and "Run As" -> "Run Configurations..."

  2. where it says "User settings" click on the File button and add the settings.xml.

  3. I think this is specific to your project but my "Goals" is set to "clean install" and I checked on "Skip Tests."

0

This helped me:

From the IDE (Red Hat CodeReady Studio in my case, but @mavaddat-javid has verified in VS Code 1.77.0).

Windows -> Show View -> Terminal -> Open/Add local terminal

Run commands as follows >

$ cd /pom-file-path/

$ mvn -U clean install

Not the answer you're looking for? Browse other questions tagged or ask your own question.