Friday, May 29, 2009

Artifactory Sent Error 401 to Maven 2 Build

Yesterday our build system had problem. It was caused by our Maven 2 process receiving response code 401. I looked up for the meaning of this 401. Google showed me that it is an Authentication Error.

[sourcecode lang="shell"]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: http://localhost:9999/artifactory/libs-snapshots-local/com/companyname/modulename/artifactname-1.2.0-20090528.051102-1.jar. Return code is: 401
[/sourcecode]

We use Apache Maven 2 as our standard build cycle. Some component depends on snapshots of other components. All software components were stored in our local Maven 2 repository, server by an Artifactory server; also running in the same application server with Hudson. The problem that I mentioned before was caused by Artifactory didn't really accept the authentication sent by Maven client process.

I dig up some more, and eventually found out that somehow we were missing the settings.xml file which was supposed to be there before. It is located in your $USER_HOME/.m2 folder. So I copied back the file, restart the application server. It works again like magic.

3 comments:

  1. I am having this same issue and have spend a few hours trying to get it resolved. Where exactly did you put your settings.xml file?

    I have my settings.xml file in /usr/share/tomcat6/.m2/

    However, I temporarily changed artifactory to allow anonymous users to deploy, and I still get an "Authorization failed: Access denied" message. If I point my browser to the URL it spits out, I get a 404 error (Not found).

    If I set up the repository path in my POM and run "deploy" from the command line, it works fine.

    Any ideas?

    ReplyDelete
  2. The best information i have found exactly here. Keep going Thank you

    ReplyDelete
  3. @LnddMiles: thanks.

    ReplyDelete