Strategy for debugging surefire “The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?”

后端 未结 11 816
野的像风
野的像风 2020-12-05 02:11

I am working on a rather complex java project with many dependencies and many unit tests.

I am using java 1.6.0_65 on mac (mavericks) with maven 3.0.5 with maven-sur

相关标签:
11条回答
  • 2020-12-05 03:01

    FWIW, I have experienced this error when the JVM ran out of memory during the maven build. On linux this was detected by OOM killer, which ended up generating kernel messages like Aug 28 20:53:27 ip-xxx-xxx-xxx-xxx kernel: [248686.775455] java invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0.

    I guess on a mac you'd just want to monitor your memory usage with ActivityMonitor.

    0 讨论(0)
  • 2020-12-05 03:05

    Following Maven Surefire documentation, you can execute the forked VM in debug mode, if it always fails. You can then debug your code until it exit.

    0 讨论(0)
  • 2020-12-05 03:07

    Changing the configuration of the plugin should resolve the problem:

    <project>
      [...]
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M1</version>
            <configuration>
              <useSystemClassLoader>false</useSystemClassLoader>
            </configuration>
          </plugin>
        </plugins>
      </build>
      [...]
    </project>
    

    As suggested in this post and in the main documentation of the plugin.

    0 讨论(0)
  • 2020-12-05 03:07

    I just delete all the maven repository and run maven clean install. Then the issue is gone.

    0 讨论(0)
  • 2020-12-05 03:09

    Steps:

    (1) Run mvn with the -e and -X options to get more debug information.

    (2) Look for "Error" in the output. In my case, when I ran the mvn command, part of the output included:

    [ERROR] Command wascmd.exe /X /C "C:\dev\dev-tools\.....
    

    (3) Execute the problematic command directly in the command shell.

    In my case, executing

    cmd.exe /X /C "C:\dev\dev-tools\....
    

    from the command line resulted in an OutOfMemoryError.

    0 讨论(0)
提交回复
热议问题