100

I have an Eclipse setup with m2eclipse and subversive. I have imported a maven2 project from svn. But I get the error message that a whole bunch of artifacts are missing (for instance: Missing artifact org.springframework:spring-test:jar:3.0.1.RELEASE:test).

If I look in my repository I see the jar files there but they have an extra extension .lastUpdated. Why is maven appending .lastUpdated to the jars? And more importantly: how can I fix this?

There is no mention of the type lastUpdated in my POMs.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
user303158
  • 1,071
  • 2
  • 7
  • 5

9 Answers9

70

These files indicate to Maven that it attempted to obtain the archive by download, but was unsuccessful. In order to save bandwidth it will not attempt this again until a certain time period encoded in the file has elapsed. The command line switch -U force maven to perform the update before the retry period. This may be necessary if you attempted to build while disconnected from the network.

The method of removing the files works with most versions of maven, but since the files are internal mementos to maven, I would not recommend this method. There is no guarantee that this information is not referenced or held elsewhere and such manipulation can damage the system.

Jörn Guy Süß
  • 1,408
  • 11
  • 18
  • I tried mvn -U clean, but it didn't fix the problem. Am I missing something? – MiguelMunoz Sep 28 '17 at 00:32
  • Your last statement in the first paragraph sounds like a contradiction to me as a newbie on the subject matter - This may be necessary if you attempted to build while disconnected from the network. If I am attempting while disconnected, then -U will try downloading from remote repository and will fail, as per my interpretation of what you said. – Sandeepan Nath Jul 27 '19 at 08:32
  • I meant, "setting -U may become necessary if you have attempted to build while disconnected from the network, and the marker has been set." – Jörn Guy Süß Aug 02 '19 at 03:32
  • what do you recommend then instead? just leave as it is, and stop the project? – eyurdakul Jul 14 '21 at 14:34
15

As rperez said, I use to delete all those .lastUpdated files. In Linux I have created a little script to keep it simple:

find -name \*.lastUpdated -exec rm -fv {} +

Just create a file with the previous content and put it on your local Maven repository. Usually it will be ~/.m2/repository.

Community
  • 1
  • 1
Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
  • 3
    in zsh: `rm ~/.m2/repository/**/*.lastUpdated` – Dacav Oct 18 '13 at 16:35
  • 6
    You can also just use find's `delete` flag to delete the files it finds, instead of `exec`ing `rm` on the results. For example, `find ~/.m2 -name *.lastUpdated -delete` – spaaarky21 Jul 09 '14 at 14:26
7

I installed Maven2 and ran mvn compile from the command line. This seems to have resolved the problem

user303158
  • 1,071
  • 2
  • 7
  • 5
  • Compile using the command line resolved this issue for me. I think this might be a m2eclipse problem. – TAN70 Jun 14 '12 at 01:58
  • 1
    Running on Windows 7 Professional SP 1, in 2017, I had similar issues with the Eclipse plug-in, and have abandoned it in favor of the CLI, which gives much more complete, usable reports that I can save, import into Excel, and generate all sorts of useful reports covering missing packages, files that didn't download, unpaired POMs and JARs, and other useful statistics. – David A. Gray Oct 04 '17 at 08:01
2

If you hit this problem and you're using Nexus, it might be the case that you have a routing rule defined, which is incorrect. I hit this myself and the files it was downloading were correctly named, at the proper URL-s it was looking at, but they were all with the .lastUpdated extension and an error message as contents.

carlspring
  • 31,231
  • 29
  • 115
  • 197
2

you might have a problem with some of the artifacts to be retrieved from the repository. for example spring framework has its own repository. this xtension is appended when the artifact cannot fully downloaded. add the spring framework repository to your pom or settings.xml, delete the folder that include the broken jars and start again

rperez
  • 8,430
  • 11
  • 36
  • 44
  • Agree. Instead of a valid pom or jar, usually a pom or jar ended with a lastUpdate is only 2k size, whose contents is more like an error log. Usually is a result of "failed to collect dependencies at ... " – Tiina Oct 12 '16 at 05:52
  • That's an interesting way of thinking of them; I've always thought of them as separate entities (lastupdated files), rather than the JARs or POMs about which they are reporting. In the same way, I think of MyDotNetAssembly.exe.config as a distinct file type from MyDotNetAssembly.exe. – David A. Gray Oct 04 '17 at 08:05
0

Open your terminal, navigate to your Eclipse's project directory and run:

mvn install

If mvn install doesn't update your dependencies, then call it with a switch to force update:

mvn install -U

This is a much safer approach compared to tampering with maven files as you delete ".lastUpdated".

Edward Quixote
  • 350
  • 5
  • 16
  • 1
    I have the same problem and `mvn install -U` didn't help. `mvn clean install` didn't do the job as well – roxch Aug 13 '19 at 10:50
0

Use this command inside the .m2/repository dir to rename all files:

for file in `find . -iname *.lastUpdated`; do renamed=$(echo $file | rev | cut -c13- | rev); echo renaming: $file to $renamed; mv $file $renamed; done

This is usefull to not download all sources again.

This not work... The .jar is lost. :(

0

What I do when I encounter this issue:

Make sure you have the version of the latest 'maven-source-plugin' plugin: https://maven.apache.org/plugins/maven-source-plugin/usage.html

$ mvn source:jar install 

Now if the file *.lastUpdate exist in your local ~/.m2/repositories/your-lib/0.0.1/ directory you can just remove it then run the command above again.

0

This is a side-effect of a failure to successfully extract from the repository. To get the actual content you want into your repository, check for correct paths to the repository/repositories within your pom file, and resolve certificate/security issues, if any. It is almost invariably one or the other of these issues.

There is no need to delete the .lastUpdated entries, and doing so won't solve your problem.

theRiley
  • 1,077
  • 13
  • 16