mvn将快照部署到nexus oss失败,返回代码为500内部错误

时间:2013-12-19 17:59:32

标签: maven deployment nexus

我使用maven将工件部署到sonatype nexus,我可以正常执行发布操作,但部署快照失败。

  • sonatype nexus 2.7.0.5
  • Java 1.7
  • maven 3.0.5

    1. mvn release:prepare; mvn release:perform;成功没有任何错误
    2. mvn deploy失败,返回码为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]"

这是我第一次将快照部署到远程存储库,因此nexus服务器上的快照存储库中没有任何内容

  • 的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>

5 个答案:

答案 0 :(得分:3)

回答自己。

当nexus服务器找不到maven-metadata.xml时,会导致tomcat抛出异常,这就是问题

我将Tomcat版本从6.x更改为7.0.x,一切正常

答案 1 :(得分:1)

Nexus需要符合Servlet 3.0标准的容器。它捆绑了一个符合Servlet 3.0标准的Jetty 8.如果你将它部署在另一个容器上,你必须确保它是兼容的。无法在文件中找到这一点,但从自己的经验来看似乎就是这样。

当你

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

在浏览器中,您应该能够看到包含

的堆栈跟踪

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

这仅适用于Servlet 3.0容器。

答案 2 :(得分:1)

我遇到了相同的返回码(500)和原因(内部服务器错误),并且finnaly发现nexus服务器磁盘空间已满。 :)检查服务器中的nexus日志可以找到这个线索。

答案 3 :(得分:0)

在我的案例中报告的错误类似:

Failed to transfer file: 
 http://192.168.0.2:8080/repository/maven-snapshots/org/xxxx/xxx-yyy/1.0-SNAPSHOT/maven-metadata.xml. 
Return code is: 500 , ReasonPhrase:Server Error.

在我执行@hansi建议的http文件验证后,服务器响应为javax.servlet.ServletException: java.lang.NumberFormatException: null

在对这是什么原因进行一些审查后,我发现这是因为工件创建时间戳的问题。在我的情况下,maven-metadata.xml已损坏,这是由于服务器中的重新启动导致在夏令时完成后自动调整时间。我在这篇文章https://issues.sonatype.org/browse/NEXUS-12496

中得到了一些线索

在我的案例中,有效的是删除所有工件引用中的maven-metadata.xml。之后,错误得到纠正。

答案 4 :(得分:0)

在这里我们失败了。

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

然后我们无法获取该版本的快照,因此我们在pom.xml文件中手动进行操作 更新为相关的依赖项详细信息,然后它将起作用。