Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am getting 401 error while deploying in nexus. I does not make any changes to the installed nexus. Nexus is running on localhost:8080/nexus and i am able to login with default user/password. When i am running mvn deploy i am getting this error.

Here is my POM.

 <groupId>testproject</groupId>
 <artifactId>testproject</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>testproject</name>
 <url>http://maven.apache.org</url>
 <distributionManagement>
  <repository>
      <id>releases</id>
      <url>http://localhost:8080/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
       <id>snapshots</id>
       <url>http://localhost:8080/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>
<dependencies>
 .........
</dependencies>

and ~/.m2/settings.xml

<servers>
    <server>
        <id>snapshots</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
    <server>
        <id>releases</id>
        <username>deployment</username>
        <password>deployment123</password>
    </server>
</servers>

Exception:

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-           deploy) on project testproject: Failed to deploy artifacts: Could not transfer artifact testproject:testproject:jar:1.0-20131213.150615-1 from/to snapshots (http://localhost:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproject/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar. 
Return code is: 401 -> [Help 1]

Please help me.

share|improve this question
    
Failed to transfer file: http://localhost:8080/nexus/content/repositories/snapshots/testproject/testproje‌​ct/1.0-SNAPSHOT/testproject-1.0-20131213.150615-1.jar. Does the file exist? – t0mppa Dec 13 '13 at 15:30
    
no, Its not uploaded to the nexus. But exists in my local target directory. – Gangaraju Dec 13 '13 at 15:33
up vote 7 down vote accepted

Its working now. Need to edit $M2_HOME/conf/settings.xml instead of /home/user/.m2/settings.xml

share|improve this answer
1  
That indicates that you were running the maven execution as a different user thant "user". You should not need to do that. – Manfred Moser Dec 16 '13 at 16:58
    
Oh my good! , you save my night , thx it works perfectly – Adnen Chouibi Apr 4 at 21:56
    
@Gangaraju men ur awesome u saved my day but i cant get why /home/user/.m2/settings.xml dosent work – Haithem Rihane Apr 4 at 21:57
1  
Thanks @AdnenChouibi,@HaithemRihane. I did not spend much time on it as it solves my problem. My observation was it's working if we install maven using apt-get install and it's not working if we unzip the maven tar and exported in $PATH. – Gangaraju Apr 5 at 4:03

HTTP 401 is the status code for "unauthorized", which implies that your deployment user isn't authorized to upload artifacts to that particular repository in Nexus. Log in to Nexus and give the deployment user the role(s) required to to change that snapshot repo.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.