ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Schlaifer <>
Subject Problem with junit in ant with jdk 1.4.1
Date Sun, 17 Nov 2002 01:15:10 GMT
Please see the java source file and build.xml that follow.  Running java
1.4.1_01 under linux as shown by

onofre:2:138 % java -version
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)

ant 1.5.1 as shown by

onofre:2:140 % ant -version
Apache Ant version 1.5.1 compiled on October 2 2002

and junit 3.7.

When I run the small test program (included below) directly

onofre:2:145 % java -classpath junit.jar:. myTest

OK (6 tests)

it runs successfully.  Also, when I run it under ant with fork="true", it
runs successfully.  When I run it under ant with fork="false", it
generates a

     [java] java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl

error.  The build.xml included belowe runs both the unforked and the
forked cases in that order as seen below.

onofre:2:141 % ant
Buildfile: build.xml


     [java] java.lang.NoClassDefFoundError: sun/reflect/ConstructorAccessorImpl


     [java] OK (6 tests)


Total time: 2 seconds

I have also found that when I comment out any one of the six test cases,
it runs fine either forked or unforked.  Finally, when I switch back to
jdk 1.3, it also runs without error.

I've run out of ideas about what to try and am hoping somebody else
recognizes this or has suggestions.


       "Perhaps God gave man free will so he
       could choose to stop those who had chosen evil."
       <James Lileks>
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.framework.TestResult;

public class myTest extends TestCase {

    public myTest(String name) {

    public static Test suite() throws ClassNotFoundException {
        return new TestSuite(Class.forName("myTest"));

    public void test0() { }
    public void test1() { }
    public void test2() { }
    public void test3() { }
    public void test4() { }
    public void test5() { }

    public static void main(String[] argv) throws Exception {
        Test suite = suite();
        junit.textui.TestRunner runner = new junit.textui.TestRunner();
        TestResult result = new TestResult();;

<?xml version="1.0"?>

<project name="Test" default="test" basedir=".">

  <property name="JUnitJar" value="junit.jar"/>

  <target name="compile">
    <javac srcdir=".">
      <include name=""/>
        <pathelement location="${JUnitJar}"/>
        <pathelement path="."/>

  <target name="testNoFork" depends="compile">
    <java classname="myTest" fork="false">
        <pathelement location="${JUnitJar}"/>
        <pathelement path="." />

  <target name="testFork" depends="compile">
    <java classname="myTest" fork="true">
        <pathelement location="${JUnitJar}"/>
        <pathelement path="." />

  <target name="test" depends="testNoFork,testFork"/>


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

View raw message