java.lang.OutOfMemoryError: Java heap space in Maven

Kiedy uruchamiam maven test, java.lang.OutOfMemoryError happens. Google go dla rozwiązań i próbowałem export MAVEN_OPTS=-Xmx1024m, ale to nie działa. Ktoś zna inne rozwiązania tego problemu, BTW używam maven 3.0

Z góry dzięki

Wklej tutaj komunikat o błędzie podczas uruchamiania "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
Author: skaffman, 2010-11-01

8 answers

Kiedy uruchamiam maven test, java.lang.OutOfMemoryError happens. Google go dla rozwiązań i próbowałem wyeksportować MAVEN_OPTS= - Xmx1024m, ale to nie działa.

Ustawienie opcji Xmx za pomocą MAVEN_OPTS działa, konfiguruje JVM używany do uruchomienia Mavena. To powiedziawszy, maven-surefire-plugin forks nowy JVM domyślnie, a Twoje {[2] } nie są więc przekazywane.

Aby skonfigurować rozmiar JVM używanego przez maven-surefire-plugin, należy albo trzeba:

  • Zmień forkMode to never (co jest niezbyt dobrym pomysłem, ponieważ Maven nie będzie odizolowany od testu)~ or ~
  • użyj argLine parametr (właściwy sposób):

W późniejszym przypadku, coś takiego:

<configuration>
  <argLine>-Xmx1024m</argLine>
</configuration>

Ale muszę powiedzieć, że zazwyczaj zgadzam się ze Stephenem tutaj, jest bardzo prawdopodobne, że coś nie tak z jednym z Twoich testów i nie jestem pewien, czy dawanie więcej pamięci jest dobrym rozwiązaniem "solve "(hide? twój problem.

Referencje

 145
Author: Pascal Thivent,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-11-02 00:37:28

Dla tych, którzy są nowi w Mavenie (tak jak ja), oto cały config, który znajduje się w sekcji budowania Twojego pom. Zdrowie.

<build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19</version>
        <configuration>
            <argLine>-Xmx1024m</argLine>
        </configuration>
      </plugin>
    </plugins>
  </build>
 57
Author: user738048,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-11-02 16:55:58

Są szanse, że problem jest w jednym z testów jednostkowych, o które poprosiłeś Mavena.

Jako takie, manipulowanie rozmiarem sterty jest złym podejściem. Zamiast tego powinieneś spojrzeć na test jednostkowy, który spowodował OOME i spróbować dowiedzieć się, czy jest to wina testu jednostkowego lub kodu, który testuje.

Zacznij od spojrzenia na ślad stosu. Jeśli go nie ma, Uruchom mvn ... test ponownie z opcją -e.

 8
Author: Stephen C,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-09 10:57:20

Rozwiązałem ten problem po mojej stronie na 2 sposoby:

  1. Dodanie tej konfiguracji w pom.xml

    <configuration><argLine>-Xmx1024m</argLine></configuration>
    
  2. Przełącz na używany JDK 1.7 zamiast 1.6

 5
Author: Minh Dang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-12-19 09:50:42

Aby tymczasowo obejść ten problem, znalazłem następujący sposób, aby być najszybszym sposobem:

export JAVA_TOOL_OPTIONS="-Xmx1024m -Xms1024m"
 5
Author: Max Hohenegger,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-13 14:40:17

W celu rozwiązania Javy.lang.OutOfMemoryError: Java heap space w Maven, spróbuj skonfigurować poniższą konfigurację w pom

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${maven-surefire-plugin.version}</version>
     <configuration>
        <verbose>true</verbose>
        <fork>true</fork>
        <argLine>-XX:MaxPermSize=500M</argLine>
    </configuration>
</plugin>
 1
Author: Narayan Yerrabachu,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-02-11 20:49:23

Ustaw zmienną środowiskową:

MAVEN_OPTS=" - Xmx1024m "

 -1
Author: saurabh prakash,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-09 10:39:30

Nie tylko pamięć sterty. zwiększ również rozmiar perm, aby rozwiązać ten wyjątek w maven użyj tych zmiennych w zmiennej środowiskowej.

variable name: MAVEN_OPTS
variable value: -Xmx512m -XX:MaxPermSize=256m

Przykład:

export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=500m"
 -1
Author: Errabi Ayoub,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-09 10:52:01