335

I am trying to set up a project using Maven (m2eclipse), but I get this error in Eclipse:

Description Resource Path Location Type Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:2.0.2 from/to central (http://repo1.maven.org/maven2): No response received after 60000 ExampleProject Unknown Maven Problem

Any ideas? It would be helpful if you could show me how to check if everything is configured fine...

Deepak Joy Cheenath
  • 5,796
  • 5
  • 25
  • 29

25 Answers25

816

Remove all your failed downloads:

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

For windows:

cd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i

Then rightclick on your project in eclipse and choose Maven->"Update Project ...", make sure "Update Dependencies" is checked in the resulting dialog and click OK.

sgsi
  • 382
  • 1
  • 8
  • 18
Jonas Andersson
  • 8,678
  • 2
  • 19
  • 14
  • 10
    In Windows I used the explorer dialog to search for *.lastUpdated in %USERPROFILE%\.m2 then deleted the files that Eclipse reported as problematic. Worked a treat! I'm sure you could do it using findstr or similar but the GUI worked. – Mark McDonald Jul 25 '12 at 04:28
  • 5
    In Windows, I brought up a Windows Explorer and right-clicked on .m2 -> Search... . I put *.lastUpdated in the file name and "Could not transfer" in the "A word or phrase in the file" text box. – rajah9 Oct 24 '12 at 13:50
  • 6
    In windows, those files are located inside `/.m2/repository/org/example/myTool/1.01` (you see the trick). Just delete them (the `*.lastUpdated`) by hand and update dependencies. – Cedric Reichenbach Dec 10 '12 at 16:59
  • 3
    Under Eclipse Luna (4.4 milestone) on Windows I found that after deleting *.lastUpdated I also needed to get m2eclipse to Reindex the Local Repository (via Eclipse->Window->Preferences->Maven->User Settings:Local Repository: Reindex) – gb96 Jan 29 '14 at 23:25
  • If it doesn't work on your first try, try checking all dependent projects as well - that worked for me. – Tom Aug 28 '14 at 13:31
  • I have the same problem under eclipse Indigo on Windows, but after following all the steps maven download them whith the ".lastupdate" extension, i dont know how to resolve that if any one can help – Tarik Dec 01 '14 at 14:07
  • i stuck with this problem, i had my system format before system format i had worked on same eclipse now i am using but i get this above errors while importing maven project pls help – Yogesh Doke Feb 23 '16 at 17:46
  • NOTE: It is important that you clean your eclipse projects BEFORE updating the maven dependencies. – It may also be necessary to select "Force update of snapshots/releases" – CubeJockey Sep 28 '16 at 15:28
  • Also may be helpfull check proxy settings in maven's settings.xml (http://stackoverflow.com/questions/23490556/maven-error-failure-to-transfer) and check which settings and repository used in eclipse (via Eclipse->Window->Preferences->Maven->User Settings:Global settings and "Update settings" button) – Nashev Dec 14 '16 at 14:41
  • 4
    after pulling my hairs for hours ...finally this solution worked for me in eclipse neon .... thankyou – Tayab Hussain Mar 18 '17 at 09:37
  • for me only had to do this step: "Then rightclick on your project in eclipse and choose Maven->"Update Project ...", make sure "Update Dependencies" is checked in the resulting dialog and click OK." – nommer Jul 13 '17 at 18:22
  • @JonasAndersson could you please explain the first command; what are piping with find command? – Govinda Sakhare Apr 07 '18 at 07:57
  • After deleting everything from .m2 I updated. It works. To update right click on project --> Maven-->update. – pravin kottawar Mar 10 '19 at 06:12
  • Windows command line does not work. Using explorer do. If you want to download sources or javadocs, better delete the " m2e-lastUpdated.properties " files too. – Jonathan Drapeau May 30 '19 at 13:51
  • Worked for me too the command prompt delete, Windows 10 here. But my local repository is different, you can see yours in Eclipse > Window > Preferences > Maven > User Settings. – Dudaskank Mar 18 '20 at 19:06
  • I needed to [delete the folder](https://stackoverflow.com/a/6127360/109747) as well. – Afriza N. Arief Apr 11 '20 at 16:57
  • tried all the solution: "updating with force update of snapshot" , 2. deleting .last updated files and "updating with force update of snapshot" but still it is not working – lupin Jul 04 '22 at 06:30
  • somedays you wish that you shouldn't be into IT job, one problem after another keeps hitting you and whole days goes surfing SO instead of twitter / FB LOL – vikramvi Sep 01 '22 at 11:14
76

This worked for me in Windows as well.

  1. Locate the {user}/.m2/repository (Using Juno /Win7 here)
  2. In the Search field in upper right of window, type ".lastupdated". Windows will look through all subfolders for these files in the directory. (I did not look through cache.)
  3. Remove them by Right-click > Delete (I kept all of the lastupdated.properties).
  4. Then go back into Eclipse, Right-click on the project and select Maven > Update Project. I selected to "Force Update of Snapshots/Releases". Click Ok and the dependencies finally resolved correctly.
NewUser
  • 3,729
  • 10
  • 57
  • 79
iowatiger08
  • 1,892
  • 24
  • 30
  • 1
    Also found that if you have incorrect references (syntax or version number) to libraries, they will not download. Use the Maven online repository search tool to make sure you are referencing the libraries correctly in your pom.xml. – iowatiger08 Jan 04 '13 at 20:51
  • This worked for windows. Thanks a lot man! But this issue reoccurs at times. Do we have any permanent fix? – LINGS Aug 15 '13 at 17:34
  • @iowatiger08 what happens if I remove the lastupdated.properties files also? – garg10may Feb 18 '16 at 12:40
  • @garg10may I dont think removing them would be a big deal because Maven will repopulate them when it does the next "update". – iowatiger08 Feb 19 '16 at 15:59
  • @iowatiger08, There are errors if I use version like [1.0.0,2.0.0) in my pom file, but I change the version to 1.6.10, the errors gone. Why this happens? – gfan Sep 05 '16 at 11:44
  • my goal was to setup Simple Maven Java GitHub project in one machine and then setup the same in another machine by retrieving the project from GitHub - I had this issue in the 2nd machine and above instructions resolved it. – Sai Oct 25 '16 at 14:40
  • Personally I would like to know what the heck causes this error...cause for sure, when creating a new maven project, in the Neon.1 release of Eclipse, the error is out of the box if the above file exists and needs to be fixed...very very annoying for instance for a Newbie to have this, cause it is an immediate blocker...I am not a newbie, and I found it demoralizing. – Beezer Jan 15 '17 at 14:35
  • thnx a tonne! this worked! maven is a pain to use in offline mode. – raikumardipak Nov 29 '18 at 10:02
45

In Eclipse: Right click the project->Maven->Update Project->Check checkbox "Force Update of Snapshots/Releases". Click OK.

Zhenya
  • 6,020
  • 6
  • 34
  • 42
20

Thanks for the replies, but after some more searching I was able to fix the problem. It turned out that I had to remove one of the "*.lastUpdated" which was preventing one of my plugins (Maven Surefire Plugin) from updating. I did this manually, because a maven clean wasn't doing it apparently.

The problem was that the "*.lastUpdated" file for a plugin was blocking the maven check for updates and not allowing a necessary jar to get downloaded.

Deepak Joy Cheenath
  • 5,796
  • 5
  • 25
  • 29
  • 4
    Maybe it's obvious, but I'd just like to add: After manually looking for the specified *.lastUpdated file in maven repository (surefire's one in my case), and deleting it, one has to clean the project in Eclipse. – superjos Jul 03 '11 at 18:36
18

Try to execute

mvn -U clean

or Run > Maven Clean and Maven > Update snapshots from project context menu in eclipse

Lev Khomich
  • 2,247
  • 14
  • 18
13

In my case. The issues is same reason. I see the problem is on proxy and firewall.

Here my solution
Fisrt ways:
1. install Proxy for Maven and Eclipse
2. Go to Locate the {user}/.m2/repository and Remove all the *.lastupdated files
3. Go back into Eclipse, Right-click on the project and select Maven > Update Project. > Select "Force Update of Snapshots/Releases".

If the project is still exist error. example: here is my issues after all above step

Failure to transfer org.apache.maven:maven-archiver:pom:2.5 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-archiver:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Connect timed out

I use this solution useful for me:
1. Find repository in https://mvnrepository.com/
2. Copy dependency to my *.poml of project
example

<dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-archiver</artifactId>
    <version>2.5</version>
</dependency>


3. Build project. the dependency missing will be downloaded to local repository.
4. Go back into Eclipse, Right-click on the project and select Maven > Update Project. > Select "Force Update of Snapshots/Releases".
=>> Error is resolved
5. I remove dependencies at step 2 after finished and resolved. Done

huan le
  • 261
  • 5
  • 10
12

This worked for me in Windows:

  1. Locate the {user}/.m2/repository
  2. In the Search field in upper right of window, type ".lastupdated". Windows will look through all subfolders for these files in the directory.
  3. Remove all the .lastupdated files.
  4. Go back into Eclipse, Right-click on the project and select Maven > Update Project.
  5. Select "Force Update of Snapshots/Releases".
  6. Click Ok and the dependencies will finally resolve correctly.
Robert Longson
  • 118,664
  • 26
  • 252
  • 242
sumeet kumar
  • 351
  • 3
  • 15
8

It happened to me as Iam behind a firewall. The dependencies doesn't get downloaded sometimes when you are running in Eclipse IDE. Make sure you use mvn clean install -U to resolve the problem. You would see the dependencies download after this.

Kran
  • 69
  • 1
  • 3
  • Once you do this on your terminal, head to Eclipse, select project and "Refresh Project". This should solve the problem without introducing the difficulty of finding and deleting ".lastUpdated". – Edward Quixote Jan 18 '19 at 01:52
5

If you are behind a proxy, you have to update the settings.xml file (under the conf folder of your MAVEN_HOME, the file itself contains information about the proxy settings) and additionally you may need to update your Eclipse Network Settings (Window->Preferences...-> type Network Connections).

Try using -X or --debug in order to get the debug output, this could provide additional information about the problem.

Abel Morelos
  • 1,228
  • 5
  • 20
  • 31
4

I had similar issue in Eclipse 3.6 with m2eclipse.

Could not calculate build plan: Failure to transfer org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 from http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 from central (http://repo1.maven.org/maven2): ConnectException project1 Unknown Maven Problem

Deleting all maven*.lastUpdated files from my local reository (as Deepak Joy suggested) solved that problem.

Luki
  • 41
  • 3
2

I had a similar issue with only a few projects in my workspace. Other projects with nearly identical POMs didn't have an error at all. None of the other answers listed fixed my problem. I finally stumbled upon removing/re-applying the Maven nature for each project and the errors disappeared:

For each project that has a pom with the "resolution will not be reattempted..." error:

  1. Right-click on the project in Eclipse and select Maven->Disable Maven Nature
  2. Right-click on the project in Eclipse and select Configure->Convert to Maven Project
smith.gt
  • 109
  • 1
  • 4
2

It Happened to me also you may have two solue=tion for this

  1. If your project consist of some external or project specificdependency in it then you have to manually add it to your M2 repo folder which is located at C:\Users\Mohit.Singh.m2\repository folder and then you have to run mvn eclipse:eclipse and then mvn clean install from the project folder

  2. if you do not have any wxternal or project sppecific dependency then you may import the project into eclipse as Existing maven project then right click on project --> GO to maven --> Click on update project a window will appear check the force snapshot download option and hit on OK

Mohit Singh
  • 5,977
  • 2
  • 24
  • 25
2

Give correct maven setting.xml path in eclipse.

  • Windows --> Preference --> Maven --> User Settings

Enter correct setting.xml path in user settings text box

1

just delete the archetype in maven local repository. As said above, it happens in case of failed archetype downloads.

Pravat Panda
  • 1,060
  • 2
  • 13
  • 27
1

For me I just added the bellow xml code in the POM.xml file. And after I dit **right click in the project -> Maven -> Update Project and I checked Force Update of Snapshots/Releases ** and every thing worked

    <dependencies>
        <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/jstl/jstl -->
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
Lamine BA
  • 129
  • 1
  • 8
1

In my case, it was a wrong version of Java being used (7 instead of 8). Hope it can still help somebody!

To quickly change the java version, you can either specify (or change, if already present) the JAVA_HOME environment variable and add its bin/ to the PATH in Windows or use this command for Linux.

update-alternatives --config java

In-depth guide here.
Note that, for Windows, you have to restart your computer to apply the changes. If you are using an IDE, then probably it's using a different JDK than your system.

0

You could delete the .m2 folder itself and force MyEclipse to re-download all dependencies on startup. Go to Window > Preferences > MyEclipse > Maven4MyEclipse.

R Tiwari
  • 325
  • 3
  • 9
0
  • Above Error occured due to removing of 'maven-compiler-plugin 2.0.2' from maven repository.
  • For me, Above error gets resolved when I downgrade 'maven-compiler-plugin' to version to either 2.0 or 2.0.1.
Avinash Pande
  • 1,510
  • 19
  • 17
0

for mac

I removed all the old failed downloads of maven there were several versions of maven also on my mac

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

after that, I simply updated my eclipse by

help -> check for updates

and the problem resolved for me

the main reason for this problem is the failed old updates does not allow you to download archetype so if you try to build project in any archetype of maven it gets failed

0

create a file delete_lastUpdated_and_remote.sh(use \n):

#!/bin/bash
find $(cd $(dirname $0); pwd) -name "*.lastUpdated" -type f -print -exec rm -rf {} \;
find $(cd $(dirname $0); pwd) -name "_remote.repositories" -type f -print -exec rm -rf {} \;

Put it in the local Maven repo, such as %userprofile%\.m2\repository or ~/.m2/repository, and run it.

In windows, you should install Git to run sh file also.

I also use it in jenkins job.

林万程
  • 351
  • 3
  • 9
0

I got this error for the plugin below:

<groupId>org.codehaus.mojo</groupId>  
<artifactId>jaxb2-maven-plugin</artifactId>  
<version>2.5</version>  

I modified tag version to:

<version>2.5.0</version>  

Then open Context menu on your project in eclipse and choose Maven > "Update Project ...", make sure "Update Dependencies" is checked in the dialog box and hit "OK" button.

Shadyar
  • 709
  • 8
  • 16
0

In my case, I got this error message in spring tool 4

ArtifactTransferException: org.codehaus.plexus:plexus-interpolation:jar:1.26 failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-interpolation:jar:1.26 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org java.lang.reflect.InvocationTargetException

Here is the solution

step 01 - first close the spring tool Application

step 02 - go to path C:\Users\User and Delete .m2 folder

folder location

step 03 - Now go to package Explore and select your project

Package Explorer

step 04 - Now Right Click on your project and go to the Maven and click Update Project

Update Project

How to uninstall Spring Tool 4

step 01 - click on Help and Go to the About Spring Tool Suite 4

enter image description here

step 02 - Now click on Installation Details

Installation Details

step 03 - inside of that you can see the all Installed Software, simply press Ctrl + A to select all and click Uninstall

Uninstall

Dhamith Kumara
  • 499
  • 5
  • 9
0

settings.xml for proxy? and in eclipse there are maven global\local profile, add the settings.xml

roi
  • 21
  • 1
  • 2
    Can you edit your answer and add more detail? Give an example of what to add to `settings.xml` and where it can be found. Also, keep in mind this question is 10 months old. – Brigand Dec 23 '11 at 02:28
-1

The solution that work for me is the following:

  1. Copy the dependency to pom.

    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-archiver</artifactId>
        <version>2.5</version>
    </dependency>
    
  2. Click right on your project

  3. Select Maven
  4. Select Update project
  5. Select Force Update of Snapshots/Releases
Jorge Santos Neill
  • 1,635
  • 13
  • 6
-1

Remove all files inside repository.

Go to C:\Users\DELL.m2\repository, select all the files and delete it.

Then go to project, right click maven update project (Alt+F5). It will download all the dependent files inside repository.

Vikas Gaurav
  • 244
  • 1
  • 6
  • 19