Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: Failed to deploy artifacts, Acces denied

Tags:

maven

nexus

I have a Sonatype Nexus server and I want to deploy a snapshot.

This is a snippet of my settings.xml file:

<servers>
  <server>
    <id>test-snapshots</id>
    <username>myname1</username>
    <password>mypasswd1</password>
  </server>
  <server>
    <id>test-releases</id>
    <username>myname2</username>
    <password>mypasswd2</password>
  </server>
</servers>

And this a snippet of my pom.xml file:

<distributionManagement>
  <repository>
    <id>test-releases</id>
    <name>Releases</name>
    <url>https://nxs.company.com/content/repositories/test-releases</url>
  </repository>
  <snapshotRepository>
    <id>test-snapshots</id>
    <name>Snapshots</name>
    <url>https://nxs.company.com/content/repositories/test-snapshots</url>
  </snapshotRepository>
</distributionManagement>

Doing a mvn deploy (Maven 3.0.3) I get this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy 
(default-deploy) on project MyProject: Failed to deploy artifacts: 
Could not transfer artifact com.company.project:MyProject:jar:1.0.0-20121003.154427-1 
from/to test-snapshots (https://nxs.company.com/content/repositories/test-snapshots): 
Access denied to: https://nxs.company.com/content/repositories/test-snapshots/
com.company.project/MyProject/1.0.0-SNAPSHOT/MyProject-1.0.0-20121003.154427-1.jar
-> [Help 1]

And in my Nexus logfile, I see that no credentials are received, so it will try it later with anonymous and this will of course fail. So why are no credentials passed to Nexus?

2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.apache.shiro.session.mgt.DefaultSessionManager - Unable to resolve session ID from SessionKey [org.apache.shiro.web.session.mgt.WebSessionKey@791a17dc].  Returning null to indicate a session could not be found.
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - No authorization found (header or request parameter)
2012-10-03 17:24:14 DEBUG [1027496148-8353] - org.sonatype.nexus.security.filter.authc.NexusContentAuthenticationFilter - Attempting to authenticate Subject as Anonymous request...
2012-10-04 17:24:14 DEBUG [1027496148-8353] - org.sonatype.security.ldap.realms.DefaultLdapContextFactory - Initializing LDAP context using URL [ldap://10.100.100.1:3268/DC=company,DC=com] and username [[email protected]] with pooling [enabled]
like image 726
Tim Avatar asked Oct 04 '12 17:10

Tim


1 Answers

Do you really have different username/password for each repository in Nexus? This will cause a problem with the maven http wagon because the jvm caches credentials per host and even though maven presents the alternate credentials properly, the jvm won't use them. The workaround to this is to use the webdav wagon instead since this uses the apache http client instead of the jdk urlclient.

like image 155
Brian Fox Avatar answered Sep 18 '22 05:09

Brian Fox