Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Ant Junit task "fork" option doesn't work
Ant Junit task "fork" option doesn't work [message #54322] Wed, 11 June 2003 09:20 Go to next message
Eclipse UserFriend
Originally posted by: lindahoward.uk.ibm.com

Hello,

I'm quite new to the Ant and JUnit plugins for Eclipse, and I've hit
upon a problem. If I try to run a JUnit test from an Ant buildfile
(within Eclipse), it will work, but only if I don't use a forked JVM for
the test. That is:

<junit printsummary="withOutAndErr" fork="no" haltonfailure="no"> works,
but:

<junit printsummary="withOutAndErr" fork="yes" haltonfailure="no"> gives
the error:

[junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Unknown Source)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.FormatterElemen t.createFormatter(FormatterElement.java:183)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .createAndStoreFormatter(JUnitTestRunner.java:562)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .main(JUnitTestRunner.java:507)
[junit] Exception in thread "main"

In my Ant runtime classpath I have the ant.jar, optional.jar and
junit.jar from the Eclipse plugins directory, and on my project
classpath I also have junit.jar. I tried adding the xerces jars from the
plugins directory to both the ant runtime and the project classpaths,
but to no avail. If I add:

<classpath>
<pathelement
location=" c:/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar "/>
<pathelement
location="c:/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar "/>
</classpath>

to my build file it solves the problem, but I'd like a "cleaner" way of
solving it. Is there a way to tell JUnit which classpath to use when it
forks? I'm using Eclipse 2.1 with the default JRE. The test runs fine
outside of Eclipse.

Thanks in advance,

Linda Howard
Re: Ant Junit task "fork" option doesn't work [message #54619 is a reply to message #54322] Wed, 11 June 2003 15:22 Go to previous messageGo to next message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
Linda,

I highly suspect this is some of the "magic" that you get when running Ant
from the commandline.
You can see my questions on the ant-dev mailing list:
http://marc.theaimsgroup.com/?l=ant-dev&m=10439407210717 0&w=2

In the ant.jar and optional.jar there are manifest files with these entries:
Class-Path: xml-apis.jar xercesImpl.jar optional.jar xalan.jar
that help the URLClassloader(s) find the xerces classes.
We can't mimic this within Eclipse as we don't have the same library
framework (the Xerces and Ant libs are not all in the same lib directory as
in Ant).

The part I do not understand is why the includeantruntime does not handle
this?
The manifest files have been removed in the Ant1.6 stream so Ant has changed
this behavior.

So for a cleaner way all I can recommend is to try using Eclipse with Ant
1.6

HTH
Darins

"Linda Howard" <lindahoward@uk.ibm.com> wrote in message
news:bc6s96$9c3$1@rogue.oti.com...
> Hello,
>
> I'm quite new to the Ant and JUnit plugins for Eclipse, and I've hit
> upon a problem. If I try to run a JUnit test from an Ant buildfile
> (within Eclipse), it will work, but only if I don't use a forked JVM for
> the test. That is:
>
> <junit printsummary="withOutAndErr" fork="no" haltonfailure="no"> works,
> but:
>
> <junit printsummary="withOutAndErr" fork="yes" haltonfailure="no"> gives
> the error:
>
> [junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
> [junit] at java.lang.Class.forName0(Native Method)
> [junit] at java.lang.Class.forName(Unknown Source)
> [junit] at
>
org.apache.tools.ant.taskdefs.optional.junit.FormatterElemen t.createFormatte
r(FormatterElement.java:183)
> [junit] at
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .createAndStoreF
ormatter(JUnitTestRunner.java:562)
> [junit] at
>
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .main(JUnitTestR
unner.java:507)
> [junit] Exception in thread "main"
>
> In my Ant runtime classpath I have the ant.jar, optional.jar and
> junit.jar from the Eclipse plugins directory, and on my project
> classpath I also have junit.jar. I tried adding the xerces jars from the
> plugins directory to both the ant runtime and the project classpaths,
> but to no avail. If I add:
>
> <classpath>
> <pathelement
> location=" c:/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar "/>
> <pathelement
> location="c:/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar "/>
> </classpath>
>
> to my build file it solves the problem, but I'd like a "cleaner" way of
> solving it. Is there a way to tell JUnit which classpath to use when it
> forks? I'm using Eclipse 2.1 with the default JRE. The test runs fine
> outside of Eclipse.
>
> Thanks in advance,
>
> Linda Howard
>
Re: Ant Junit task "fork" option doesn't work [message #72993 is a reply to message #54619] Fri, 04 July 2003 20:15 Go to previous messageGo to next message
Chris Leon is currently offline Chris LeonFriend
Messages: 2
Registered: July 2009
Junior Member
I had the same problem as Linda, with org/w3c/dom/Node, not being found
executing JUnit tasks from Ant.

However, when I change the fork option to no, the script runs but
Eclipse promptly hangs afterwards. This is on OS X with Apple's 1.4.1,
which I've read here isn't considered that great. Is this a problem
with the JRE, or something else?

I may try the Ant 1.6 stream next... Do I just replace the ant JARs in
the plugin directory with the new ones, or install them anywhere and set
ANT_HOME in the Windows->Preferences->Ant Runtime options?

Thanks,

c

In article <bc7hc9$v1n$1@rogue.oti.com>,
"Darin Swanson" <Darin_Swanson@us.ibm.com> wrote:

> Linda,
>
> I highly suspect this is some of the "magic" that you get when running Ant
> from the commandline.
> You can see my questions on the ant-dev mailing list:
> http://marc.theaimsgroup.com/?l=ant-dev&m=10439407210717 0&w=2
>
> In the ant.jar and optional.jar there are manifest files with these entries:
> Class-Path: xml-apis.jar xercesImpl.jar optional.jar xalan.jar
> that help the URLClassloader(s) find the xerces classes.
> We can't mimic this within Eclipse as we don't have the same library
> framework (the Xerces and Ant libs are not all in the same lib directory as
> in Ant).
>
> The part I do not understand is why the includeantruntime does not handle
> this?
> The manifest files have been removed in the Ant1.6 stream so Ant has changed
> this behavior.
>
> So for a cleaner way all I can recommend is to try using Eclipse with Ant
> 1.6
>
> HTH
> Darins
>
> "Linda Howard" <lindahoward@uk.ibm.com> wrote in message
> news:bc6s96$9c3$1@rogue.oti.com...
> > Hello,
> >
> > I'm quite new to the Ant and JUnit plugins for Eclipse, and I've hit
> > upon a problem. If I try to run a JUnit test from an Ant buildfile
> > (within Eclipse), it will work, but only if I don't use a forked JVM for
> > the test. That is:
> >
> > <junit printsummary="withOutAndErr" fork="no" haltonfailure="no"> works,
> > but:
> >
> > <junit printsummary="withOutAndErr" fork="yes" haltonfailure="no"> gives
> > the error:
> >
> > [junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
> > [junit] at java.lang.Class.forName0(Native Method)
> > [junit] at java.lang.Class.forName(Unknown Source)
> > [junit] at
> >
> org.apache.tools.ant.taskdefs.optional.junit.FormatterElemen t.createFormatte
> r(FormatterElement.java:183)
> > [junit] at
> >
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .createAndStoreF
> ormatter(JUnitTestRunner.java:562)
> > [junit] at
> >
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .main(JUnitTestR
> unner.java:507)
> > [junit] Exception in thread "main"
> >
> > In my Ant runtime classpath I have the ant.jar, optional.jar and
> > junit.jar from the Eclipse plugins directory, and on my project
> > classpath I also have junit.jar. I tried adding the xerces jars from the
> > plugins directory to both the ant runtime and the project classpaths,
> > but to no avail. If I add:
> >
> > <classpath>
> > <pathelement
> > location=" c:/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar "/>
> > <pathelement
> > location="c:/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar "/>
> > </classpath>
> >
> > to my build file it solves the problem, but I'd like a "cleaner" way of
> > solving it. Is there a way to tell JUnit which classpath to use when it
> > forks? I'm using Eclipse 2.1 with the default JRE. The test runs fine
> > outside of Eclipse.
> >
> > Thanks in advance,
> >
> > Linda Howard
> >
Re: Ant Junit task "fork" option doesn't work [message #73088 is a reply to message #72993] Sat, 05 July 2003 05:55 Go to previous messageGo to next message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
> I may try the Ant 1.6 stream next... Do I just replace the ant JARs in
> the plugin directory with the new ones, or install them anywhere and set
> ANT_HOME in the Windows->Preferences->Ant Runtime options?


Set ANT_HOME to your 1.6 install. Remove the entries for the Xerces libs
Has been working great for me.

Darins

"Chris Leon" <csl@alum.dartmouth.org> wrote in message
news:csl-E07CC2.16150004072003@eclipse.org...
> I had the same problem as Linda, with org/w3c/dom/Node, not being found
> executing JUnit tasks from Ant.
>
> However, when I change the fork option to no, the script runs but
> Eclipse promptly hangs afterwards. This is on OS X with Apple's 1.4.1,
> which I've read here isn't considered that great. Is this a problem
> with the JRE, or something else?
>
> I may try the Ant 1.6 stream next... Do I just replace the ant JARs in
> the plugin directory with the new ones, or install them anywhere and set
> ANT_HOME in the Windows->Preferences->Ant Runtime options?
>
> Thanks,
>
> c
>
> In article <bc7hc9$v1n$1@rogue.oti.com>,
> "Darin Swanson" <Darin_Swanson@us.ibm.com> wrote:
>
> > Linda,
> >
> > I highly suspect this is some of the "magic" that you get when running
Ant
> > from the commandline.
> > You can see my questions on the ant-dev mailing list:
> > http://marc.theaimsgroup.com/?l=ant-dev&m=10439407210717 0&w=2
> >
> > In the ant.jar and optional.jar there are manifest files with these
entries:
> > Class-Path: xml-apis.jar xercesImpl.jar optional.jar xalan.jar
> > that help the URLClassloader(s) find the xerces classes.
> > We can't mimic this within Eclipse as we don't have the same library
> > framework (the Xerces and Ant libs are not all in the same lib directory
as
> > in Ant).
> >
> > The part I do not understand is why the includeantruntime does not
handle
> > this?
> > The manifest files have been removed in the Ant1.6 stream so Ant has
changed
> > this behavior.
> >
> > So for a cleaner way all I can recommend is to try using Eclipse with
Ant
> > 1.6
> >
> > HTH
> > Darins
> >
> > "Linda Howard" <lindahoward@uk.ibm.com> wrote in message
> > news:bc6s96$9c3$1@rogue.oti.com...
> > > Hello,
> > >
> > > I'm quite new to the Ant and JUnit plugins for Eclipse, and I've hit
> > > upon a problem. If I try to run a JUnit test from an Ant buildfile
> > > (within Eclipse), it will work, but only if I don't use a forked JVM
for
> > > the test. That is:
> > >
> > > <junit printsummary="withOutAndErr" fork="no" haltonfailure="no">
works,
> > > but:
> > >
> > > <junit printsummary="withOutAndErr" fork="yes" haltonfailure="no">
gives
> > > the error:
> > >
> > > [junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
> > > [junit] at java.lang.Class.forName0(Native Method)
> > > [junit] at java.lang.Class.forName(Unknown Source)
> > > [junit] at
> > >
> >
org.apache.tools.ant.taskdefs.optional.junit.FormatterElemen t.createFormatte
> > r(FormatterElement.java:183)
> > > [junit] at
> > >
> >
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .createAndStoreF
> > ormatter(JUnitTestRunner.java:562)
> > > [junit] at
> > >
> >
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .main(JUnitTestR
> > unner.java:507)
> > > [junit] Exception in thread "main"
> > >
> > > In my Ant runtime classpath I have the ant.jar, optional.jar and
> > > junit.jar from the Eclipse plugins directory, and on my project
> > > classpath I also have junit.jar. I tried adding the xerces jars from
the
> > > plugins directory to both the ant runtime and the project classpaths,
> > > but to no avail. If I add:
> > >
> > > <classpath>
> > > <pathelement
> > >
location=" c:/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar "/>
> > > <pathelement
> > > location="c:/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar "/>
> > > </classpath>
> > >
> > > to my build file it solves the problem, but I'd like a "cleaner" way
of
> > > solving it. Is there a way to tell JUnit which classpath to use when
it
> > > forks? I'm using Eclipse 2.1 with the default JRE. The test runs fine
> > > outside of Eclipse.
> > >
> > > Thanks in advance,
> > >
> > > Linda Howard
> > >
Re: Ant Junit task "fork" option doesn't work [message #73280 is a reply to message #73088] Sat, 05 July 2003 22:09 Go to previous messageGo to next message
Chris Leon is currently offline Chris LeonFriend
Messages: 2
Registered: July 2009
Junior Member
That doesn't seem to change things. If you don't mind, I'll describe
what I did... maybe I'm missing something.

I set the ANT_HOME to the 1.6 install, and it included all the .jar's in
there (there's lots of them now...).

I tried it this way, but Eclipse looks like it couldn't parse the Ant
file. In the Ant view, it gives this message:

class:org/apache/xerces/parsers/IntegratedParserConfiguratio n, method:
configurePipeline signature: () V) Incompatible type for getting or
setting field.

I removed the entries to the xerxes libs that are in the Ant 1.6 folder,
and get the same message.

Then I removed all the jar files aside from ant.jar and optional.jar,
and Eclipse parsed it fine. Haven't figured out which one is causing
that problem yet... the bootstrap jar that now includes the manifest
entries for the xerces jar wasn't there.

So then I tried with the original JUnit fork option of yes, using the
junit jar from it's Eclipse plugin directory. Executing with this, I
got the original NoClassDefFoundError for Node. Also tried this with a
junit jar that I got from junit.org, same result. For kicks, also tried
adding the ant-junit.jar from the Ant 1.6/lib directory, but no help.

Then I went back to using the fork option of no. The tests run, but
Eclipse promptly crashed.

Going back to Linda's original post, I added the eclipse plug-in xerxes
libs to my Junit classpath in the Ant script, and that made things work.

So for me at least, fork="no" doesn't seem to be an option at all. If
eclipse doesn't crash immediately, the GUI goes all funky, with text
insertion lines appearing on window borders, etc, forcing me to quit.
Don't know if this is an OS X thing, or if other platforms have
something similar.

fork="yes" works as long as I add explicitly add the xerces jars to the
class path.

Don't know if all that tells you anything or not... I guess for now
I'll just keep the xerces paths in the Ant script, although, as Linda
said, it'd be nice to not have to have them there.

Thanks,

Chris


In article <be5p43$sls$1@rogue.oti.com>,
"Darin Swanson" <Darin_Swanson@us.ibm.com> wrote:

> > I may try the Ant 1.6 stream next... Do I just replace the ant JARs in
> > the plugin directory with the new ones, or install them anywhere and set
> > ANT_HOME in the Windows->Preferences->Ant Runtime options?
>
>
> Set ANT_HOME to your 1.6 install. Remove the entries for the Xerces libs
> Has been working great for me.
>
> Darins
>
> "Chris Leon" <csl@alum.dartmouth.org> wrote in message
> news:csl-E07CC2.16150004072003@eclipse.org...
> > I had the same problem as Linda, with org/w3c/dom/Node, not being found
> > executing JUnit tasks from Ant.
> >
> > However, when I change the fork option to no, the script runs but
> > Eclipse promptly hangs afterwards. This is on OS X with Apple's 1.4.1,
> > which I've read here isn't considered that great. Is this a problem
> > with the JRE, or something else?
> >
> > I may try the Ant 1.6 stream next... Do I just replace the ant JARs in
> > the plugin directory with the new ones, or install them anywhere and set
> > ANT_HOME in the Windows->Preferences->Ant Runtime options?
> >
> > Thanks,
> >
> > c
> >
> > In article <bc7hc9$v1n$1@rogue.oti.com>,
> > "Darin Swanson" <Darin_Swanson@us.ibm.com> wrote:
> >
> > > Linda,
> > >
> > > I highly suspect this is some of the "magic" that you get when running
> Ant
> > > from the commandline.
> > > You can see my questions on the ant-dev mailing list:
> > > http://marc.theaimsgroup.com/?l=ant-dev&m=10439407210717 0&w=2
> > >
> > > In the ant.jar and optional.jar there are manifest files with these
> entries:
> > > Class-Path: xml-apis.jar xercesImpl.jar optional.jar xalan.jar
> > > that help the URLClassloader(s) find the xerces classes.
> > > We can't mimic this within Eclipse as we don't have the same library
> > > framework (the Xerces and Ant libs are not all in the same lib directory
> as
> > > in Ant).
> > >
> > > The part I do not understand is why the includeantruntime does not
> handle
> > > this?
> > > The manifest files have been removed in the Ant1.6 stream so Ant has
> changed
> > > this behavior.
> > >
> > > So for a cleaner way all I can recommend is to try using Eclipse with
> Ant
> > > 1.6
> > >
> > > HTH
> > > Darins
> > >
> > > "Linda Howard" <lindahoward@uk.ibm.com> wrote in message
> > > news:bc6s96$9c3$1@rogue.oti.com...
> > > > Hello,
> > > >
> > > > I'm quite new to the Ant and JUnit plugins for Eclipse, and I've hit
> > > > upon a problem. If I try to run a JUnit test from an Ant buildfile
> > > > (within Eclipse), it will work, but only if I don't use a forked JVM
> for
> > > > the test. That is:
> > > >
> > > > <junit printsummary="withOutAndErr" fork="no" haltonfailure="no">
> works,
> > > > but:
> > > >
> > > > <junit printsummary="withOutAndErr" fork="yes" haltonfailure="no">
> gives
> > > > the error:
> > > >
> > > > [junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
> > > > [junit] at java.lang.Class.forName0(Native Method)
> > > > [junit] at java.lang.Class.forName(Unknown Source)
> > > > [junit] at
> > > >
> > >
> org.apache.tools.ant.taskdefs.optional.junit.FormatterElemen t.createFormatte
> > > r(FormatterElement.java:183)
> > > > [junit] at
> > > >
> > >
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .createAndStoreF
> > > ormatter(JUnitTestRunner.java:562)
> > > > [junit] at
> > > >
> > >
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner .main(JUnitTestR
> > > unner.java:507)
> > > > [junit] Exception in thread "main"
> > > >
> > > > In my Ant runtime classpath I have the ant.jar, optional.jar and
> > > > junit.jar from the Eclipse plugins directory, and on my project
> > > > classpath I also have junit.jar. I tried adding the xerces jars from
> the
> > > > plugins directory to both the ant runtime and the project classpaths,
> > > > but to no avail. If I add:
> > > >
> > > > <classpath>
> > > > <pathelement
> > > >
> location=" c:/eclipse/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar "/>
> > > > <pathelement
> > > > location="c:/eclipse/plugins/org.apache.xerces_4.0.7/xercesImpl.jar "/>
> > > > </classpath>
> > > >
> > > > to my build file it solves the problem, but I'd like a "cleaner" way
> of
> > > > solving it. Is there a way to tell JUnit which classpath to use when
> it
> > > > forks? I'm using Eclipse 2.1 with the default JRE. The test runs fine
> > > > outside of Eclipse.
> > > >
> > > > Thanks in advance,
> > > >
> > > > Linda Howard
> > > >
>
>
Re: Ant Junit task "fork" option doesn't work [message #73316 is a reply to message #73280] Sat, 05 July 2003 23:53 Go to previous message
Darin Swanson is currently offline Darin SwansonFriend
Messages: 2386
Registered: July 2009
Senior Member
> I tried it this way, but Eclipse looks like it couldn't parse the Ant
> file. In the Ant view, it gives this message:
>
> class:org/apache/xerces/parsers/IntegratedParserConfiguratio n, method:
> configurePipeline signature: () V) Incompatible type for getting or
> setting field.
>

If you are getting this, somewhere the Xerces libraries are being put on the
Ant runtime classpath and then you are getting conflicts with the Xerces
libraries that Eclipse must use (the ones in the Xerces plugin). I had no
trouble with 1.6 but I have not tried in the last month or so. Are you sure
that you did not have any other JARs in there that had a manifest entry for
the xerces libs? I know there is a lot of JARs now in that lib dir :-)

I will try to remember to look into this some more next week when I have
access to a Mac

Thanks
Darins
Previous Topic:JDT Problem
Next Topic:cvs and reserved edit and commit
Goto Forum:
  


Current Time: Wed Jul 24 15:33:14 GMT 2024

Powered by FUDForum. Page generated in 0.03864 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top