5

我的 maven 3.0.3 版本在 Jenkins 中有一个-Xmx1G和设置。-XX:MaxPermSize=500M但是,当我进行部署时,我总是得到

java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2786)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
    at sun.net.www.http.PosterOutputStream.write(PosterOutputStream.java:61)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:492)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:457)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:411)
    at org.apache.maven.wagon.AbstractWagon.transfer(AbstractWagon.java:392)
    at org.apache.maven.wagon.AbstractWagon.putTransfer(AbstractWagon.java:365)
    at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:163)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:825)
    at org.sonatype.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:465)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:278)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:215)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:480)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
    at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:188)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    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:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

要部署的工件283M很大。我该怎么做才能正确部署它?

4

2 回答 2

2

这个问题是由这个错误引起的。如链接中所建议,只需使用 webdav 进行部署。

考虑执行以下操作:

<project>
  [...]
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
        <artifactId>wagon-webdav</artifactId>
        <version>1.0</version>
      </extension>
    </extensions>  
    </plugin>
  </build>
  ...
  <distributionManagement>
    <site>
        <id>sample-project.website</id>
        <url>dav:https://dav.sample.com/sites/sample-project</url>
    </site>
  </distributionManagement>
  ...
</project>

我以前遇到过这个问题。我相信它只发生在 >= 256 MB 的工件上。

切换到 webdav 部署方式后,还可以减少内存设置。(如果您只是由于部署期间的内存问题而专门修改了它们)。

于 2012-12-10T11:41:41.720 回答
1

这个答案简单地说@olamy 是对的:升级到 maven 3.0.4 解决了这个问题。

于 2012-12-11T14:59:55.457 回答