Search code examples
javamavennexussonatype

Receiving 401 error code while doing a release:perform from my maven build


I've been receiving an error while trying to release a new version of software to Sonatype. I've successfully completed mvn release:prepare but when I do mvn release:perform I get the following error:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:52.660s
[INFO] Finished at: Fri Feb 14 22:32:52 EST 2014
[INFO] Final Memory: 28M/263M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project flexjson: Failed to deploy artifacts: Could not transfer artifact net.sf.flexjson:flexjson:jar:3.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/net/sf/flexjson/flexjson/3.2/flexjson-3.2.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:00.122s
[INFO] Finished at: Fri Feb 14 22:32:52 EST 2014
[INFO] Final Memory: 14M/184M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:perform (default-cli) on project flexjson: Maven execution failed, exit code: '1' -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal   org.apache.maven.plugins:maven-release-plugin:2.0:perform (default-cli) on project flexjson:   Maven execution failed, exit code: '1'
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
 Caused by: org.apache.maven.plugin.MojoExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:135)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.apache.maven.shared.release.ReleaseExecutionException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:90)
at org.apache.maven.shared.release.phase.RunPerformGoalsPhase.execute(RunPerformGoalsPhase.java:67)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:343)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:289)
at org.apache.maven.shared.release.DefaultReleaseManager.perform(DefaultReleaseManager.java:269)
at org.apache.maven.plugins.release.PerformReleaseMojo.execute(PerformReleaseMojo.java:131)
... 21 more
Caused by: org.apache.maven.shared.release.exec.MavenExecutorException: Maven execution failed, exit code: '1'
at org.apache.maven.shared.release.exec.ForkedMavenExecutor.executeGoals(ForkedMavenExecutor.java:122)
at org.apache.maven.shared.release.exec.AbstractMavenExecutor.executeGoals(AbstractMavenExecutor.java:47)
at org.apache.maven.shared.release.exec.ForkedMavenExecutor.executeGoals(ForkedMavenExecutor.java:144)
at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:82)
... 26 more

I found blog post about the error, but I don't see anything that matches my setup.

http://blog.sonatype.com/2010/11/what-to-do-when-nexus-returns-401/#.Uv7EYEKwJUI

The post refers to the settings file not matching what's configured in the pom. But I don't have anything in the pom about deployment. I don't have a plugin configured so it must've been using the default plugin configuration for doing releases. As I understand it that's the maven release plugin.

This setup has worked in the past, but I'm doing this from another machine. I had to generate a new gpg private key following this post:

http://blog.sonatype.com/2010/01/how-to-generate-pgp-signatures-with-maven/#.Uv2JUkKwJUI

This setup has worked before, but I've moved to the new machine. I made sure to copy the .m2/settings.xml file to my ~/.m2/settings.xml. Of course that private key is different than the one I had on my old machine. But I can't figure out why that matters or if that matters. From what I've read it's just for code signing. Not sure how that authorizes code signings.

So what am I missing? Why does this 401 error keep happening?


Solution

  • [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project flexjson: Failed to deploy artifacts: Could not transfer artifact net.sf.flexjson:flexjson:jar:3.2 from/to sonatype-nexus-staging (https://oss.sonatype.org/service/local/staging/deploy/maven2/): Failed to transfer file: https://oss.sonatype.org/service/local/staging/deploy/maven2/net/sf/flexjson/flexjson/3.2/flexjson-3.2.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

    regenerate your maven master password and encrypt your password for your nexus repository and configure it in your ~/.m2 settings.xml