ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keith Hatton" <>
Subject RE: Ant 1.6 and JUnit - NoClassDefFoundError
Date Wed, 07 Jan 2004 14:05:53 GMT
Hi Tanguy,

Removing xalan.jar makes no difference (except that I suspect other tasks might fail later
on). I am wondering whether the problem arises because I am using JDK 1.3 which does not include
the org.w3c.dom classes, and the xmlApis.jar or similar is not included in the classpath for
the JUnit task any more (previously, everything in ANT_HOME/lib was included). There is something
in the release notes about <taskdef>ing such tasks to define classpaths in a more controlled
manner than Ant 1.5 and I wonder whether I might have to look into that in more detail.


-----Original Message-----
From: RADEMAKERS Tanguy []
Sent: 07 January 2004 13:47
To: Ant Users List
Subject: Re: Ant 1.6 and JUnit - NoClassDefFoundError

Hello Keith,

I don't *think* you need xalan.jar in the ANT_HOME/lib any more - have 
you tried removing it? There are some other jars in there that might 
here's my test:

C:\TanguyLand>echo %JAVA_HOME%

C:\TanguyLand>echo %CLASSPATH%
%CLASSPATH% <- i.e. no classpath

C:\TanguyLand>echo %ANT_HOME%

C:\TanguyLand>ls %ANT_HOME%/lib
AntDoc.jar               ant-jakarta-regexp.jar  ant-trax.jar
README                   ant-javamail.jar        ant-vaj.jar
ant-antlr.jar            ant-jdepend.jar         ant-weblogic.jar
ant-apache-bsf.jar       ant-jmf.jar             ant-xalan1.jar
ant-apache-resolver.jar  ant-jsch.jar            ant-xalan2.jar
ant-commons-logging.jar  ant-junit.jar           ant-xslp.jar
ant-commons-net.jar      ant-launcher.jar        ant.jar
ant-icontract.jar        ant-netrexx.jar         junit.jar
ant-jai.jar              ant-nodeps.jar          log4j-1.2.8.jar
ant-jakarta-bcel.jar     ant-starteam.jar        xercesImpl.jar
ant-jakarta-log4j.jar    ant-stylebook.jar       xml-apis.jar
ant-jakarta-oro.jar      ant-swing.jar

C:\TanguyLand>ls -R
bin  build  build.xml  dist  doc  lib  scrap  src



AllTests.class  CalcUtilities.class  CalcUtilitiesTest.class



AllTests.class  CalcUtilities.class  CalcUtilitiesTest.class









C:\TanguyLand>more build.xml
<?xml version="1.0"?>
<project name="TanguyLand" basedir="." default="compile">
        <!-- properties -->
        <property name="source.dir" location="src"/>
        <property name="build.dir" location="build"/>
        <property name="doc.dir" location="doc"/>
        <property name="javadoc.dir" location="${doc}/api"/>
        <property name="dist.dir" location="dist"/>
        <property name="lib.dir" location="lib"/>
        <property name="" value="tanguyland.jar"/>
        <!--<property name="junit.tests.failed" value="false"/>-->
        <!-- classpaths -->
        <path id="compile.class.path">
                <fileset dir="${lib.dir}" includes="**/*.jar"/>

        <!-- targets -->
        <target name="init">
                <mkdir dir="${build.dir}"/>
                <mkdir dir="${dist.dir}"/>

        <target name="compile" depends="init" description="compile the 
                <javac destdir="${build.dir}" deprecation="on">
                        <src path="${source.dir}"/>
                        <classpath refid="compile.class.path"/>

        <target name="clean" description="empties the dist and build 
                <delete includeemptydirs="true" failonerror="false">
                        <fileset dir="${build.dir}"/>
                        <fileset dir="${dist.dir}"/>

        <target name="dist" depends="compile" description="makes the 
distributable jar file">
                <jar destfile="${dist.dir}/${}"

        <target name="test" depends="compile" description="runs the 
junit tests">
                <junit printsummary="on" 
failureproperty="${junit.tests.failed}" showoutput="no">
                                <formatter type="plain" usefile="false"/>
                                <fileset dir="${build.dir}">
                                        <include name="**/*Test*.class"/>
                                        <exclude name="**/AllTests.class"/>
                                <pathelement location="${build.dir}"/>
                <fail if="${junit.tests.failed}" message="there are 
failed JUnit tests. See output."/>

        <target name="all" depends="clean,test,dist" description="clean 
build, test and jar of the whole app"/>

C:\TanguyLand>ant test
Buildfile: build.xml



    [junit] Running org.tanguyland.CalcUtilitiesTest
    [junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.016 sec

    [junit] Testsuite: org.tanguyland.CalcUtilitiesTest
    [junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 0.016 sec

    [junit] Testcase: testAdd took 0.016 sec
    [junit] Testcase: testSubtract took 0 sec
    [junit] Testcase: testMultiply took 0 sec
    [junit] Testcase: testDivide took 0 sec

Total time: 1 second

Keith Hatton wrote:

>I'm just taking a look at Ant 1.6 and I'm having a problem with a build file that works
fine in 1.5.3.
>java -version gives 1.3.1
>ant -version gives 1.6
>The only changes to the standard installation is that I've copied junit.jar and xalan.jar
into ANT_HOME/lib (which I did for Ant 1.5) - prior to this the build complained that it couldn't
find JUnit classes.
>Now for *every* test suite in the build I get the following error.
>    [junit] java.lang.NoClassDefFoundError: org/w3c/dom/Node
>    [junit]     at java.lang.Class.forName0(Native Method)
>    [junit]     at java.lang.Class.forName(
>    [junit]     at
>    [junit]     at
>    [junit]     at
>    [junit]     at
>I'm guessing that this must have something to do with the re-packaing of JARs in ANT_HOME/lib
or the scary bit in the release notes about changes to classloaders. If anyone has come across
similar problems, or has ideas for how to fix this, I'd be glad to hear from them.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message