DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • How to Submit a Post to DZone
  • How to LINQ Between Java and SQL With JPAStreamer
  • Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023
  1. DZone
  2. Data Engineering
  3. Data
  4. How to Resolve Maven's ''Failure to Transfer'' Error

How to Resolve Maven's ''Failure to Transfer'' Error

Learn how to resolve the ''failure to transfer'' error encountered in Maven in this quick tutorial.

Jose Roy Javelosa user avatar by
Jose Roy Javelosa
·
Sep. 24, 14 · Tutorial
Like (3)
Save
Tweet
Share
114.66K Views

Join the DZone community and get the full member experience.

Join For Free

Here is a quick solution for those encountering the “Failure to Transfer” error in Maven.
The error message will most likely look something like this


Failure to transfer <DEPENDENCY> from <REPOSITORY>
was cached in the local repository, resolution will not be reattempted until 
the update interval of central has elapsed or updates are forced.

This is a documented issue in Maven’s jira page.

When an artifact is unable to be downloaded, Maven 3 caches this result for future reference in the “~/.m2/repo/…/<artifact>.lastUpdated” file. For “not found” situations, it seems that the HTTP code could be used to more granularly re-attempt retrieval rather than just cache the failure.

For example, for any 404, I agree, the result should cache the failure and require a -U to attempt to retrieve it again. However, for 400, 500, 501, 502, 503, 301, 302 (what’s the Maven behavior for 3xx today?) I think the resolution engine should try to re-retrieve the artifact each time. With those error codes, it seems more likely a config issue or brief network hiccup, not one of the file being absent from that repo. However, that brief network hiccup has longstanding cache implications in that the file is never attempted to be retrieved again.

The easiest way to resolve this is to delete the dependencies or artifacts which maven has appended with the .lastUpdated prefix.  Only after that can you successfully Update Dependencies of your maven project.
But deleting all these artifacts from your maven repository one by one every time this occurs is not an ideal solution.
The most simple solution is suggested by Jonas Anderson in Stackoverflow.

For Unix Users

  1. find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;
  2. Right click your project and choose Update Dependencies

For Windows

  1. CD (change directory) to
    <user-directory>\.m2\repository
  2. execute this command
    for /r %i in (*.lastUpdated) do del %i
  3. Right click your project and choose Update Dependencies
Apache Maven Cache (computing) Dependency Artifact (UML) Error message Network JOnAS Del (command)

Published at DZone with permission of Jose Roy Javelosa, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • How to Submit a Post to DZone
  • How to LINQ Between Java and SQL With JPAStreamer
  • Avoiding Pitfalls With Java Optional: Common Mistakes and How To Fix Them [Video]
  • An Overview of Kubernetes Security Projects at KubeCon Europe 2023

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: