You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署快照Jar至远程Nexus时遇unexpected end of stream异常求助

解决远程Nexus部署Jar文件时的"unexpected end of stream"错误

你遇到的问题是部署快照Jar到远程Nexus OSS 3.7.1-02时,只有pom、md5、sha1能成功上传,Jar文件失败并抛出unexpected end of stream异常——这通常和网络连接中断、Nexus配置限制或者Maven传输组件的问题有关。下面是几个针对性的排查和解决方法:

1. 优先排查网络连接稳定性

这个错误最常见的诱因是大文件传输过程中网络中断,毕竟Jar文件体积远大于pom和校验文件:

  • 用浏览器直接上传一个测试Jar到目标Nexus仓库,验证网络是否能稳定传输大文件
  • 如果是跨区域/跨运营商网络,尝试切换到更稳定的环境,或者配置合规的代理
  • 检查Nexus服务器侧的防火墙、负载均衡器是否限制了文件上传的大小或超时时间

2. 调整Nexus的上传配置限制

Nexus默认的存储或超时设置可能不足以支撑Jar文件上传:

  • 登录Nexus管理后台,进入proj-snapshots仓库的配置页面,在Storage板块确认Blob Store的大小限制是否足够,必要时调整
  • 编辑Nexus的全局配置文件nexus.properties,延长jetty.http.idleTimeout参数(比如设置为300000即5分钟),修改后重启Nexus服务

3. 升级Maven Deploy插件并调整传输组件

你当前使用的maven-deploy-plugin2.8.2版本偏老,同时Takari Aether连接器可能存在传输兼容问题:

  • 在pom.xml中升级插件到最新稳定版(比如3.1.1):
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-deploy-plugin</artifactId>
      <version>3.1.1</version>
    </plugin>
  </plugins>
</build>
  • 尝试切换回Maven默认的Wagon连接器,在pom.xml或settings.xml中添加配置:
<build>
  <extensions>
    <extension>
      <groupId>org.apache.maven.wagon</groupId>
      <artifactId>wagon-http</artifactId>
      <version>3.5.3</version>
    </extension>
  </extensions>
</build>

4. 延长Maven的传输超时时间

在settings.xml中给目标服务器配置更长的超时时间,确保Jar文件有足够时间完成传输:

<servers>
  <server>
    <id>proj-repository</id>
    <username>你的Nexus用户名</username>
    <password>你的Nexus密码</password>
    <configuration>
      <httpConfiguration>
        <all>
          <timeout>300000</timeout> <!-- 5分钟超时 -->
        </all>
      </httpConfiguration>
    </configuration>
  </server>
</servers>

5. 验证本地Jar文件的完整性

偶尔Jar文件本身损坏也会导致传输异常:

  • 用jar tf api-core-0.0.1-20180103.144552-1.jar命令检查本地Jar的文件结构是否正常
  • 重新执行mvn clean package生成新的Jar文件后再尝试部署

完整错误堆栈参考

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project api-core: Failed to deploy artifacts: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project api-core: Failed to deploy artifacts: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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: Failed to deploy artifacts: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream
at org.apache.maven.plugin.deploy.DeployMojo.deployProject(DeployMojo.java:284)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:169)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:171)
at org.apache.maven.plugin.deploy.DeployMojo.deployProject(DeployMojo.java:250)
... 23 more
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
... 25 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.proj.api:api-core:jar:0.0.1-20180103.144552-1 from/to proj-repository (http://<nexus_url>/nexus/repository/proj-snapshots): unexpected end of stream
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:895)
at io.takari.aether.connector.AetherRepositoryConnector$2.wrap(AetherRepositoryConnector.java:1)
at io.takari.aether.connector.AetherRepositoryConnector$PutTask.flush(AetherRepositoryConnector.java:743)
at io.takari.aether.connector.AetherRepositoryConnector.put(AetherRepositoryConnector.java:345)
at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
... 28 more
Caused by: java.net.ProtocolException: unexpected end of stream
at com.squareup.okhttp.internal.http.HttpConnection$FixedLengthSink.close(HttpConnection.java:314)
at okio.RealBufferedSink.close(RealBufferedSink.java:241)
at okio.RealBufferedSink$1.close(RealBufferedSink.java:209)
at com.google.common.io.Closer.close(Closer.java:214)
at io.takari.aether.connector.AetherRepositoryConnector$FileSource.copyTo(AetherRepositoryConnector.java:147)
at io.takari.aether.okhttp.OkHttpAetherClient$2.writeTo(OkHttpAetherClient.java:141)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:887)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:749)
at com.squareup.okhttp.Call.getResponse(Call.java:268)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
at com.squareup.okhttp.Call.execute(Call.java:79)
at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:167)
at io.takari.aether.okhttp.OkHttpAetherClient.put(OkHttpAetherClient.java:161)
at io.takari.aether.connector.AetherRepositoryConnector$PutTask.run(AetherRepositoryConnector.java:715)
at io.takari.aether.connector.AetherRepositoryConnector.put(AetherRepositoryConnector.java:332)
... 29 more

内容的提问来源于stack exchange,提问作者Rajeshwari Natarajan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:10:47