“Forked Java VM exited abnormally” error from juni

2019-01-17 09:37发布

I have a java junit test that passes when run alone on a development machine. We also have a hudson job which runs all the tests, invoked via ant, on a Mac OS X 10.4 node with Java 1.5. The test was passing in the hudson build until recently but now (with no related code changes) one test fails everytime with the following error:

Error Message

Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.

Stacktrace

junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.

googling shows many others seem to have run into the same problem but there I couldn't find any answer.

16条回答
2楼-- · 2019-01-17 10:06

For me, it was an "java.lang.OutOfMemoryError" in the forked VM (junit task with fork="yes") which made this message appear in the main VM.

The OutOfMemory was visible in the ant log (well, is visible since it's still present).

I use ant 1.7.1, so no hope with upgrading ant.

After putting the same VM parameters in "Run>External tools>External tools>JRE" than in Eclipse.ini (-Xms40m -Xmx512m -XX:MaxPermSize=256M) the problem is solved.

I keep fork to "no" to be sure ant use the parameters.

查看更多
别忘想泡老子
3楼-- · 2019-01-17 10:08

I believe I saw this error once when I ended up with multiple versions of junit on my classpath. Might be worth checking out.

查看更多
Bombasti
4楼-- · 2019-01-17 10:09

I faced a similar issue. I ran the junit tests as an ant task. I added the showoutput="yes" ant junit property and ran the ant junit task. It then showed the exception stack trace that caused the forked jvm to exit.

查看更多
Deceive 欺骗
5楼-- · 2019-01-17 10:09

Is the VM crashing ? Can you find a dump file (called hs_err_pid*.log) ? If that's the case, the dump file will give you clues to why this is crashing out.

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-01-17 10:09

I faced the same issue. The problem was with byte code generation with mocking the Config class; We changed the import to

import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

and it worked.

查看更多
我只想做你的唯一
7楼-- · 2019-01-17 10:12

I faced the problem after reinstalling a new version of NetBeans to an external hard disk, upgrading Junit at the same time and using my old workspace.

For me the solution to the same problem was simple:

Just add the JUnit-Library to project properties => Libraries => Compile Tests and Run Tests.

So, in my case, it was just a missing library or a JUnit version conflict.

查看更多
登录 后发表回答