可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
This question already has an answer here:
While running of unit tests following exception occurs:
org.apache.maven.lifecycle.LifecycleExecutionException: ExecutionException; nested exception is java.util.concurrent.ExecutionException: java.lang.RuntimeException: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) at org.apache.maven.cli.MavenCli.main(MavenCli.java:362) at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:600) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Any suggestions?
回答1:
Any suggestions?
The exception's error message probably explains what is going on. One of your unit tests has either
- called
System.exit()
, or - broken the unit test harness, or
- done something that has crashed the JVM in which it was running.
We cannot tell you which it was.
(I imagine that the problem is being reported because the maven JVM was expecting the child JVM to write the unit test results to its standard output. What it got back from the child was missing the message (or whatever) that said that the unit tests had finished. It is possible that the root cause might be different from the alternatives suggested, but I doubt it, and it is pointless speculating ...)
There is possibly more information in the logfile for the offending unit test. Check that / them.
回答2:
I was facing the same issue while running maven goal "package". The issue was resolved when i executed the goal "clean" before executing "package"
回答3:
I've had the same issue. Turned out I updated my libs without updating my java version, and I had a little too new servlet.jar. I found following message in the logs, prior to the 'forked VM bla exception':
Caused by: java.lang.UnsupportedClassVersionError: javax/servlet/ServletRequest : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getMethod0(Class.java:2670) at java.lang.Class.getMethod(Class.java:1603) at org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod(ReflectionUtils.java:57) at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isSuiteOnly(JUnit3TestChecker.java:64) at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.isValidJUnit3Test(JUnit3TestChecker.java:59) at org.apache.maven.surefire.common.junit3.JUnit3TestChecker.accept(JUnit3TestChecker.java:54) at org.apache.maven.surefire.common.junit4.JUnit4TestChecker.accept(JUnit4TestChecker.java:51) at org.apache.maven.surefire.util.DefaultScanResult.applyFilter(DefaultScanResult.java:97) at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:194) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:92)
Updating JVM helped.
回答4:
I was having this same problem ONLY in jenkins as reported in the accepted answer and lost one hour to realize that the problem was that the jenkins job name had a space in it, this was making something (still don't know what) in the invocation of the surefire plugin go crazy since the job name is the folder inside the jenkins workspace where everything is.
So, to be clear, jenkins has nothing to do with the problem, I only saw it in jenkins because only there I had a space in my path
I hope this helps someone else. This was under surefire 2.14.1 and 2.16.
回答5:
This may have to do with Administrator rights. I was facing the same issue when running the build mvn clean install
from Cygwin.
Now everytime for build I start cygwin as "Run as administrator" and the problem is solved.