当我运行maven测试时,java.lang.OutOfMemoryError
发生了。我在谷歌上搜索它的解决方案,并试图export MAVEN_OPTS=-Xmx1024m
,但它没有工作。有人知道这个问题的其他解决方案吗?我正在使用maven 3. 0
运行mvn test -e
时在此处粘贴错误消息
Failed tests:
warning(junit.framework.TestSuite$1)
testDefaultPigJob_1(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
testDefaultPigJob_2(com.snda.dw.pig.impl.DefaultPigJobLocalTest)
Tests run: 11, Failures: 3, Errors: 0, Skipped: 0
10/11/01 13:37:18 INFO executionengine.HExecutionEngine: Connecting to hadoop fi
le system at: file:///
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.063s
[INFO] Finished at: Mon Nov 01 13:37:18 PDT 2010
[INFO] Final Memory: 3M/6M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.
5:test (default-test) on project dw.pig: There are test failures.
[ERROR]
[ERROR] Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports fo
r the individual test results.
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project
dw.pig: There are test failures.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:199)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:148)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:140)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures
.
Please refer to E:\Code\Java\workspace\dw.pig\target\surefire-reports for the in
dividual test results.
at org.apache.maven.plugin.surefire.SurefirePlugin.execute(SurefirePlugi
n.java:629)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:195)
... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExc
8条答案
按热度按时间cigdeys31#
对于那些新的Maven(像我一样),这里是整个配置,去在您的pom的建设部分。干杯。
dfty9e192#
问题很可能出在您要求Maven运行的某个单元测试中。
因此,调整堆大小是错误的方法。相反,您应该查看导致OOME的单元测试,并试图找出是单元测试的错误还是正在测试的代码的错误。
首先查看堆栈跟踪,如果没有,使用
-e
选项再次运行mvn ... test
。j5fpnvbx3#
为了暂时解决这个问题,我发现以下是最快的方法:
czq61nw14#
我已经解决了这个问题在我这边的2种方式:
1.在pom.xml中添加此配置
1.切换到使用的JDK 1.7而不是1.6
zte4gxcn5#
正如前面的答案中所提到的,由于Surefire正在创建一个新的JVM来运行测试,您希望将该
-Xmx1024m
传递给新的JVM,而不是传递给启动mvn test
的JVM。只是想补充一下,您可以在命令中执行此操作,例如
它与将JVM选项添加到pom.xml中的Surefire插件配置中具有相同的效果:
k7fdbhmy6#
为了解决java.lang.OutOfMemoryError问题:Maven中的Java堆空间,尝试在pom中配置以下配置
ezykj2lf7#
不仅堆内存。还要增加perm大小以解决Maven中异常,并在环境变量中使用这些变量。
示例:
66bbxpm58#
当我运行Maven测试时,发生了java.lang.OutOfMemoryError。我在谷歌上搜索解决方案,并尝试导出MAVEN_OPTS=-XMX 1024 M,但没有成功。
使用
MAVEN_OPTS
设置Xmx
选项确实有效,它确实配置了用于启动Maven的JVM。也就是说,maven-surefire-plugin默认派生一个新的JVM,因此您的MAVEN_OPTS
不会被传递。要配置maven-surefire-plugin使用的JVM的大小,您必须执行以下操作之一:
forkMode
更改为never
(这不是一个好主意,因为Maven不会与测试隔离)~或~argLine
参数(正确方法):在后一种情况下,事情是这样的:
但是我不得不说,我倾向于同意Stephen的观点,您的某个测试很可能有问题,我不确定提供更多内存是否是“解决”(隐藏?)您的问题的正确解决方案。
参考