This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 166379 - Use extexecution in JavaRunner (old Ant in dep => JUnit failure)
Summary: Use extexecution in JavaRunner (old Ant in dep => JUnit failure)
Status: REOPENED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 4 votes (vote)
Assignee: Tomas Zezula
URL:
Keywords:
: 166856 166879 216586 (view as bug list)
Depends on: 205359 206783
Blocks: 145980 232370
  Show dependency tree
 
Reported: 2009-06-02 06:56 UTC by Masaki Katakai
Modified: 2013-07-09 16:28 UTC (History)
8 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Project that reproduce the error (15.24 KB, application/x-zip-compressed)
2012-10-01 08:37 UTC, johan.sehlstedt
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki Katakai 2009-06-02 06:56:50 UTC
It seems that older version of ant is defined in pom.xml, test fails by
the following error. In this case, 1.5.4 is defined, which is older than
bundled ant version. I'll attach the sample project.

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

Output window:

WARNING: multiple versions of ant detected in path for junit 
        
jar:file:/Applications/NetBeans/NetBeans%206.7%20RC1.app/Contents/Resources/NetBeans/java2/ant/lib/ant.jar!/org/apache/tools/ant/Project.class
     and jar:file:/Users/katakai/.m2/repository/ant/ant/1.5.4/ant-1.5.4.jar!/org/apache/tools/ant/Project.class
Testsuite: jp.javelindev.mvntestsample.AppTest
Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.064 sec

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.tools.ant.util.FileUtils.close(Ljava/io/Writer;)V
        at
org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter.endTestSuite(XMLJUnitResultFormatter.java:177)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.fireEndTestSuite(JUnitTestRunner.java:714)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:547)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1031)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:888)
Test jp.javelindev.mvntestsample.AppTest FAILED (crashed)
test:

If it's not possible to solve it, I think it's better to give useful
warning so that users could use newer version of ant in the projects.
Comment 1 Masaki Katakai 2009-06-02 07:00:02 UTC
sample project

mvntestsample.zip
http://ja.netbeans.org/servlets/GetAttachment?list=netcat67&msgId=2038623&attachId=1
Comment 2 Milos Kleint 2009-06-02 10:18:37 UTC
the problem is primary in the CompileOnSave/Quick runner API/implementation which is backed by ant execution, the Maven
support just feeds the project classpath to it. reassigning. We might filter out ant from classpath, but I consider that
suboptimal (as the project might still fail but in more subtle ways..

A possible workaround for maven projects is to disable the Compile On Save feature for test execution. Alternatively
setting the IDE's ant version to 1.5.x could also help.
Comment 3 Jesse Glick 2009-06-02 15:47:39 UTC
The proper fix is to not use Ant scripts to implement JavaRunner to begin with. This was promised for a post-6.5 release
but apparently it was neglected for 6.7. We now have extexecution and this should be used.
Comment 4 Milan Kubec 2009-07-03 12:10:43 UTC
*** Issue 166856 has been marked as a duplicate of this issue. ***
Comment 5 Milan Kubec 2009-07-03 12:11:26 UTC
*** Issue 166879 has been marked as a duplicate of this issue. ***
Comment 6 Jesse Glick 2009-07-06 18:48:18 UTC
If we use extexecution from JavaRunner, especially if that can create a pty on Unix, we could consider deleting
ForkedJavaOverride in the Ant module. Then if you use CoS your program would behave very much like it would from 'java
clazz.Name' on the CLI (Ant would not be involved); if not, you would get standard Ant "cooked" (buffered) I/O.
Comment 7 converginglight 2010-08-17 18:12:49 UTC
I don't know about "older ant dependencies", but with Netbeans 6.9.1 and built-in Ant (1.8.1) it is very simple to reproduce that bug:

	import org.junit.*;
	public class _JUnitVMError {
		@Test public void test1() throws Exception {
			System.exit(0);
		}
	}

Should I file a new bug for that, or is it the same?

It is especially annoying because one can't use JUnit to test "JFrame"s which have EXIT_ON_CLOSE property (they seem to make use of System.exit).

The output of above code is:

Testcase: _JUnitVMError:test1:        Caused an ERROR
Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:154)
Comment 8 Jesse Glick 2010-08-17 19:15:09 UTC
(In reply to comment #7)
> one can't use JUnit to test "JFrame"s which
> have EXIT_ON_CLOSE property (they seem to make use of System.exit)

Quite true. So if you want to test that JFrame directly (rather than e.g. some interior JPanel), fix it to not use EXIT_ON_CLOSE. This is just a basic testability refactoring.

> Testcase: _JUnitVMError:test1:        Caused an ERROR
> Forked Java VM exited abnormally.

This is correct. JUnit tests which exit the VM before the test runner completes normally are presumed to have crashed it.
Comment 9 Jesse Glick 2011-11-21 14:50:28 UTC
This is long overdue. If you do not plan to work on it, assign it to me.
Comment 10 naveenkvm 2012-01-06 10:35:05 UTC
(In reply to comment #9)
> This is long overdue. If you do not plan to work on it, assign it to me.

Hi,

We are using NetBeans 7.1 RC2 and we are still getting this error.
Was this bug fixed in 7.1 RC2? Or still open for all versions of NetBeans?

Following is the stacktrace we are getting:

Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

We are running integration test for a webservice.
When we right click and say 'Test File', it runs well.
But when we do 'Debug Test File' with a breakpoint, it comes to the breakpoint and stops.
After 2-3 seconds it crashes on it's own without any manual action like pressing F8.
Comment 11 naveenkvm 2012-01-06 10:35:36 UTC
(In reply to comment #9)
> This is long overdue. If you do not plan to work on it, assign it to me.

Hi,

We are using NetBeans 7.1 RC2 and we are still getting this error.
Was this bug fixed in 7.1 RC2? Or still open for all versions of NetBeans?

Following is the stacktrace we are getting:

Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
	at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)

We are running integration test for a webservice.
When we right click and say 'Test File', it runs well.
But when we do 'Debug Test File' with a breakpoint, it comes to the breakpoint and stops.
After 2-3 seconds it crashes on it's own without any manual action like pressing F8.
Comment 12 naveenkvm 2012-01-06 12:01:59 UTC
(In reply to comment #11)
> (In reply to comment #9)
> > This is long overdue. If you do not plan to work on it, assign it to me.
> 
> Hi,
> 
> We are using NetBeans 7.1 RC2 and we are still getting this error.
> Was this bug fixed in 7.1 RC2? Or still open for all versions of NetBeans?
> 
> Following is the stacktrace we are getting:
> 
> Forked Java VM exited abnormally. Please note the time in the report does not
> reflect the time until the VM exit.
> junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please
> note the time in the report does not reflect the time until the VM exit.
>     at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
> 
> We are running integration test for a webservice.
> When we right click and say 'Test File', it runs well.
> But when we do 'Debug Test File' with a breakpoint, it comes to the breakpoint
> and stops.
> After 2-3 seconds it crashes on it's own without any manual action like
> pressing F8.

If we run the test from command line maven, it passes.
But if we try to debug the test using Netbeans IDE, we get above mentioned error.
Comment 13 Jesse Glick 2012-01-06 18:25:35 UTC
(In reply to comment #10)
> Was this bug fixed in 7.1 RC2? Or still open for all versions of NetBeans?

It is still open. And please do not touch the Version field, as this represents the oldest version for which the bug was reported.

> Forked Java VM exited abnormally.

Typically that would be a bug in the VM, not the IDE, and is probably unrelated to this bug. If you can reproduce your problem from scratch, file a separate bug report.
Comment 14 naveenkvm 2012-01-09 11:08:28 UTC
(In reply to comment #13)
> (In reply to comment #10)
> > Was this bug fixed in 7.1 RC2? Or still open for all versions of NetBeans?
> 
> It is still open. And please do not touch the Version field, as this represents
> the oldest version for which the bug was reported.
> 
> > Forked Java VM exited abnormally.
> 
> Typically that would be a bug in the VM, not the IDE, and is probably unrelated
> to this bug. If you can reproduce your problem from scratch, file a separate
> bug report.

But that error is happening only if i run the Netbeans IDE in debug mode by selecting 'Debug Test File'. 
If i do 'Test file', it passes.
Why this error happens only in debug mode if it is VM problem?
Comment 15 Milos Kleint 2012-07-18 12:14:25 UTC
(In reply to comment #3)
> The proper fix is to not use Ant scripts to implement JavaRunner to begin with.
> This was promised for a post-6.5 release
> but apparently it was neglected for 6.7. We now have extexecution and this
> should be used.

->P2
Comment 16 Jiri Rechtacek 2012-09-01 13:05:13 UTC
*** Bug 216586 has been marked as a duplicate of this bug. ***
Comment 17 johan.sehlstedt 2012-10-01 08:37:42 UTC
Created attachment 125131 [details]
Project that reproduce the error
Comment 18 johan.sehlstedt 2012-10-01 08:38:44 UTC
For Bug 216586 (marked as duplicate of this bug).
One way to bypass the problem is to add the following line in the build.xml.

<property name="run.jvmargs.ide" value=""/>
Comment 19 SamMohamed 2012-10-14 05:57:12 UTC
Thanks for the workaround..... It worked for me in 7.2
I hope for a fix in 7.3
Comment 20 Tomas Zezula 2012-12-17 14:32:06 UTC
After discussion with Milos Kleint:
The maven CoS support will be reimplemented to execute maven just to bypass compile step, so this issue become useless. The JavaRunner is just support API which will be used just by Ant project.
Comment 21 Tomas Zezula 2013-07-02 13:50:00 UTC
Already fixed in maven support.
The maven CoS support is reimplemented to execute maven just to bypass compile step, so this issue is now useless.
Comment 22 Jesse Glick 2013-07-08 21:22:05 UTC
Consider comment #6, which has nothing to do with Maven; the current JavaRunner is bad for Ant-based projects too.
Comment 23 Tomas Zezula 2013-07-09 14:11:09 UTC
Based on comment #6 it still makes a sense to rewrite the JR to use ExternalProcessBuilder.