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.