我使用maven将artifact部署到sonatype nexus,我可以正常执行发布操作,但部署快照失败。
maven 3.0.5
[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服务器上的快照存储库中没有任何内容
<?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>
<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>
我遇到了相同的返回代码(500)和原因(内部服务器错误),最后发现nexus服务器磁盘空间已满。 :) 检查服务器中的nexus日志可以找到这个线索。
回答我自己。
当nexus服务器找不到maven-metadata.xml时,会导致tomcat抛出异常,这就是问题所在
我将Tomcat版本从6.x更改为7.0.x,一切正常
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 容器中可用。
这是在我的情况下报告的类似错误:
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
。之后错误被纠正。
在这里我们失败了。
然后我们无法获取该发布快照,因此我们在 pom.xml 文件中手动获取 更新到相关的依赖项详细信息然后它就可以工作了。
@gersonZaragocin Getting similar error as given below
Downloading from Nexus: http://****:9090/telecom-spec/repository/nokia-snapshot/com/mt/maven-web-application/1.0.0-SNAPSHOT/maven-metadata.xml
[DEBUG] Could not find metadata com.mt:maven-web-application:1.0.0-SNAPSHOT/maven-metadata.xml in Nexus (http://****:9090/telecom-spec/repository/nokia-snapshot/)
[DEBUG] Writing tracking file '/root/.m2/repository/com/mt/maven-web-application/1.0.0-SNAPSHOT/resolver-status.properties'
Uploading to Nexus: http://****:9090/telecom-spec/repository/nokia-snapshot/com/mt/maven-web-application/1.0.0-SNAPSHOT/maven-web-application-1.0.0-20240917.100034-1.pom
Uploading to Nexus: http://****:9090/telecom-spec/repository/nokia-snapshot/com/mt/maven-web-application/1.0.0-SNAPSHOT/maven-web-application-1.0.0-20240917.100034-1.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 18.244 s
[INFO] Finished at: 2024-09-17T10:00:52Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.1.1:deploy (default-deploy) on project maven-web-application: Failed to deploy artifacts: Could not transfer artifact com.mt:maven-web-application:pom:1.0.0-20240917.100034-1 from/to Nexus (http://****:9090/telecom-spec/repository/nokia-snapshot/): status code: 500, reason phrase: Server Error (500) -> [Help 1]
如果有人可以建议解决问题的步骤,那就太好了?