Search code examples
mavendeploymentnexus

mvn deploy snapshot to nexus oss failed with return code 500 internal error


I use maven to deploy artifact to sonatype nexus,I can perform release action normally,but deploy snapshots failed.

  • sonatype nexus 2.7.0.5
  • Java 1.7
  • maven 3.0.5

    1. mvn release:prepare;mvn release:perform; successful without any error
    2. mvn deploy failed with return code 500
[INFO] maven-jar-plugin:2.4:jar (default-jar) @ licm 
[INFO] Building jar: /foo/licm/trunk/target/licm-0.2.9-SNAPSHOT.jar
[INFO]
[INFO] maven-install-plugin:2.3.1:install (default-install) @ licm
[INFO] Installing /foo/licm/trunk/target/licm-0.2.9-SNAPSHOT.jar to /foo/.m2/repository/com/xxx/utils/licm/0.2.9-SNAPSHOT/licm-0.2.9-SNAPSHOT.jar
[INFO] Installing /foo/licm/trunk/pom.xml to /foo/.m2/repository/com/xxx/utils/licm/0.2.9-SNAPSHOT/licm-0.2.9-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.8.1:deploy (default-deploy) @ licm ---
Downloading: http://xxx.xxx.com:8080/nexus/content/repositories/snapshots/com/xxx/utils/licm/0.2.9-SNAPSHOT/maven-metadata.xml
    [WARNING] Could not transfer metadata com.xxx.utils:licm:0.2.9-SNAPSHOT/maven-metadata.xml 
from/to Snapshots (http://xxx.xxx.com:8080/nexus/content/repositories/snapshots): Failed to transfer file:
 http://xxx.xxx.com:8080/nexus/content/repositories/snapshots/com/xxx/utils/licm/0.2.9-SNAPSHOT/
maven-metadata.xml. Return code is: 500 , ReasonPhrase:Internal Server Error.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.824s
[INFO] Finished at: Fri Dec 20 01:20:33 CST 2013
[INFO] Final Memory: 8M/20M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.1:deploy (default-deploy) on project licm: Failed to retrieve remote metadata com.xxx.utils:licm:0.2.9-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.xxx.utils:licm:0.2.9-SNAPSHOT/maven-metadata.xml from/to Snapshots (http://xxx.xxx.com:8080/nexus/content/repositories/snapshots): Failed to transfer file: http://xxx.xxx.com:8080/nexus/content/repositories/snapshots/com/xxx/utils/licm/0.2.9-SNAPSHOT/maven-metadata.xml. Return code is: 500 , ReasonPhrase:Internal Server Error. -> [Help 1]"

This is my first time to deploy snapshots to remote repository,so there have nothing in snapshot repository on nexus server

  • settings.xml
   <?xml version="1.0"?>
<settings>
<servers>
<server>
        <id>Releases</id>
        <username>admin</username>
        <password>admin123</password>

</server>
<server>
        <id>Snapshots</id>
        <username>admin</username>
        <password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
        <id>Nexus</id>
        <name>Nexus Public Mirror</name>
        <url>http://xxx.xxx.com:8080/nexus/content/groups/public</url>
        <mirrorOf>*</mirrorOf>
</mirror>

</mirrors>
</settings>
  • pom.xml
<distributionManagement>
    <repository>
      <id>Releases</id>
      <name>xxx Releases Repositories</name>
      <url>http://xxx.xxx.com:8080/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
      <id>Snapshots</id>
      <name>xxx Snapshots Repositories</name>
      <url>http://xxx.xxx.com:8080/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

Solution

  • Nexus requires a Servlet 3.0 compliant container. It comes bundled with a Servlet 3.0 compliant Jetty 8. If you deploy it on another container you have to make sure it is compliant. Couldn't find this in the documtation but from own experience it seems to be the case.

    When you

    HTTP GET http://xxx.xxx.com:8080/nexus/content/repositories/snapshots/com/xxx/utils/licm/0.2.9-SNAPSHOT/maven-metadata.xml

    in a browser you should be able to see the stacktrace, which contains

    java.lang.NoSuchMethodError: javax.servlet.http.HttpServletResponse.getStatus()

    This is only available in Servlet 3.0 containers.