3

I'm working with archiva for about a year now,

I upload my jars manually through archiva GUI,and it's working fine.

Now I want to upload an artifact with maven deploy,the problem is that I get 401-Unauthorized. bare in mind that:

1.) I can download from this repository with no problem .

2.) I use admin user .

3.) I can upload with this user manually.

this is the log that I get:

[com:apinterface.parent] Downloading: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/maven-metadata.xml

[11:43:39][Step 1/3] [INFO] ------------------------------------------------------------------------
[11:43:39][Step 1/3] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project apinterface.parent: Failed to deploy artifacts: Could not transfer artifact com:apinterface.parent:pom:1.0-20140924.084338-1 from/to snapshots (http://xx.xx.xx.xx:9080/archiva/repository/snapshots): Failed to transfer file: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/apinterface.parent-1.0-20140924.084338-1.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
Shahar Hamuzim Rajuan
  • 5,610
  • 9
  • 53
  • 91

2 Answers2

7

This should be because you haven't configured Maven to use the Archiva Username/Password for uploading artifacts during the deploy phase.

I assume you have already configured the distributionManagement section in your pom file.

<distributionManagement>
    <snapshotRepository>
        <id>snapshots</id>
        <name>Internal Snapshots</name>
        <url>http://xx.xx.xx.xx:9080/archiva/repository/snapshots/</url>
    </snapshotRepository>
    <repository>
        <id>releases</id>
        <name>Internal Releases</name>
        <url>http://xx.xx.xx.xx:9080/archiva/repository/releases</url>
    </repository>
</distributionManagement>

You should have servers with matching ids in your Maven Settings file (like in the sample below) to configure the username/password which maven should use while uploading(deploy) the artifacts

<settings>
  <servers>
    <server>
      <id>snapshots</id>
      <username>archiva-user</username>
      <password>archiva-pwd</password>
    </server>
    <server>
      <id>releases</id>
      <username>archiva-user</username>
      <password>archiva-pwd</password>
    </server>
  </servers>
</settings>
carlspring
  • 31,231
  • 29
  • 115
  • 197
coderplus
  • 5,793
  • 5
  • 34
  • 54
  • In my case, I've put 'archiva.snapshots' as the id which was different from the repository ID in the archiva admin page. It has to be exactly the same. – John Doe Nov 04 '14 at 03:41
1

Optionally, you can give free access for the download by adding the Guest user access to the repositories at:

Manage -> Users (Tab)

Edit the roles and in "Repository Manager Repository Observer" select the free access repositories

enter image description here

Ronald Coarite
  • 4,460
  • 27
  • 31