Posts Tagged ‘Java’

How to resolve Maven’s “Failure to Transfer” error

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

Toad for Eclipse Plugin

You might not be aware, but there is a Toad plugin for Eclipse.  Yes Toad, (kokak) the world’s  favorite Tool for Oracle Application Developers.  This plugin is created by Quest Software themselves and is available as a FREE download from the Eclipse Market Place and from Quest Software http://www.quest.com/toad-extension-for-eclipse/

The Toad Extension for Eclipse plugin allows you to connect to your Oracle or PostgreSQL database from within Eclipse.  All you need to do is to switch into the Toad Extension perspective.  From the Toad Extension perspective you can easily browse data, develop complex PL/SQL and even edit data without the need of opening a separate IDE like Oracle SQL Developer.

TOAD EXTENSION FOR ECLIPSE FEATURES

Connections View   Displays configured database connections  
Schema Browser   Browses through schema objects  
Object Describe   Views detailed information about an object  
SQL Worksheet   Edits and executes SQL statements  
Projects and Toad Extension for Eclipse Nature   Adds additional functionality to new or existing projects  
Syntax Check   Verifies SQL code on-the-fly  
Deployment   Allows to deploy objects to database using default connection or selected connection  
Object status   Shows status of object in default database  
Export to HTML/XML/CSV   Outputs data to selected format  
SQL Recall   Views a history of your executed SQL statements  
SQL Monitor   Monitors all SQL coming from Toad Extensions  
DBMS Output View*   Views DBMS_OUTPUT results  
Stored Procedure Editor   Edits Stored Procedures, Views and Triggers  
Search dialog   Searches through database source code  
PL/Doc View*   Views column information comments  
Outline View   Views the logical structure of a database object  
Sessions View*   Monitors or kills sessions in the database  
Parameters View* Displays an overview of the database and session parameters

How to get Maven working through a proxy server

Maven, is a Yiddish word meaning accumulator of knowledge.

Maven is a tool that can now be used for building and managing any Java-based project, something that makes the day-to-day work of Java developers easier.

Maven’s Objectives

  • Making the build process easy
  • Providing a uniform build system
  • Providing quality project information
  • Providing guidelines for best practices development
  • Allowing transparent migration to new features

I personally think that mavens greatest contribution to the opensource community is the way it provides developers with  a uniform build system.  Further information about maven can be found at http://maven.apache.org/index.html and tutorials on how to use maven is just a google away.  The only problem that you might encounter with maven is how to get it working through a proxy server.

To save you time, below is the line of code you’ll append at the end of your maven command so that maven would work properly even if your using a proxy server.

-DproxySet=true -DproxyHost=ur.proxy.server -DproxyPort=port

where -DproxyHost value is “YOUR PROXY SERVERand -DproxyPort is“YOUR PORT NUMBER”

You can view your proxy settings through

Internet Explorer >> tools >> internet options >> Connections >> LAN Settings

Fire Fox >> tools >> options >> ADVANCED TAB >> settings

If you find yourself using maven from time to time specially to gather dependencies I would suggest you manually edit your maven settings.  There is an existing official tutorial on how to do this at http://maven.apache.org/guides/mini/guide-proxies.html but to save you time, below is a portion of the tutorial which I copied from their site.

You can configure a proxy to use for some or all of your HTTP requests in Maven 2.0. The username and password are only required if your proxy requires basic authentication (note that later releases may support storing your passwords in a secured keystore – in the mean time, please ensure your settings.xml file (usually ${user.home}/.m2/settings.xml) is secured with permissions appropriate for your operating system).

The nonProxyHosts setting accepts wild cards, and each host not to proxy is separated by the | character. This matches the JDK configuration equivalent.

<settings>
  .
  .
  <proxies>
   <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
    </proxy>
  </proxies>
  .
  .
</settings>

Please note that currently NTLM proxies are not supported as they have not been tested. You may be able to use the relevant system properties on JDK 1.4+ to make this work.