ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alasdair Young <>
Subject "java.lang.ClassNotFoundException" when running junit task
Date Tue, 02 Jan 2007 21:13:56 GMT

I'm trying to set up some automated builds for the first time here and
I'm using a legacy ant build script that I've been hacking away at to
get junit working.

I am running ant 1.7, Junit 4.1 and java 1.5 on fedora core 5.

When I try to get junit to run my tests via ant, I get the following:

> test:
>     [junit] Testsuite: com.vigilos.apps.setup.TestScheduledtlTableModel
>     [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
>     [junit] Null Test:  Caused an ERROR
>     [junit] com.vigilos.apps.setup.TestScheduledtlTableModel
>     [junit] java.lang.ClassNotFoundException:
> com.vigilos.apps.setup.TestScheduledtlTableModel
>     [junit]     at$
>     [junit]     at
> Method)
>     [junit]     at
>     [junit]     at java.lang.ClassLoader.loadClass(
>     [junit]     at java.lang.ClassLoader.loadClass(
>     [junit]     at java.lang.ClassLoader.loadClass(
>     [junit]     at
> java.lang.ClassLoader.loadClassInternal(
>     [junit]     at java.lang.Class.forName0(Native Method)
>     [junit]     at java.lang.Class.forName(
> /home/ayoung/vigilos/subversion/trunk/java/build.xml:42: Test
> com.vigilos.apps.setup.TestScheduledtlTableModel failed

relevant parts of build.xml:

>     <property name="test.dir"         location="../javatest"/>
>     <property name="build.test.dir"   location="build-tests"/>
>     <path id="project.classpath">
>         <pathelement
> location=".:../java/build:../thirdParty/signedJars/jh.jar:../thirdParty/signedJars/jai_codec.jar:../thirdParty/signedJars/jcchart.jar:../thirdParty/signedJars/jlfgr-1_0.jar:../thirdParty/signedJars/ojdbc14.jar:../thirdParty/signedJars/scrollabledesktop.jar:../thirdParty/signedJars/ftpbean.jar:../thirdParty/signedJars/jai_core.jar:../thirdParty/signedJars/jdbcpool-0.99.jar:../thirdParty/signedJars/log4j-1.2.5.jar:../thirdParty/signedJars/pg73jdbc3.jar:../thirdParty/unsignedJars/jmf.jar:../thirdParty/unsignedJars/commons-collections.jar:../thirdParty/unsignedJars/commons-pool-1.1.jar:../thirdParty/unsignedJars/commons-dbcp-1.1.jar:../thirdParty/signedJars/jcalendar.jar:${tomcat-dir}/common/lib/servlet-api.jar:${tomcat-dir}/common/lib/jsp-api.jar:../thirdParty/unsignedJars/junit-4.1.jar:./build-tests:../javatest:./build-tests/com/vigilos/apps/setup/TestScheduledtlTableModel.class"
> />
>     </path>

>     <target name="test">
>         <junit haltonfailure="true" fork="yes">
>         <classpath refid="project.classpath" />
>         <formatter type="brief" usefile="false" />
>         <batchtest>
>             <fileset dir="${build.test.dir}"
>                      includes="**/*.class" />
>         </batchtest>
>     </junit>
>     </target>


I have junit-4.1.jar in my $ANT_HOME/lib

The project.classpath is a mess - several items at the end were tacked
on as I tried different things.

I read the FAQ entry
( and several
blogs that also described the issue - I am not able to make any of these
resources useful to me. Either they don't apply or my lack of
understanding is getting in the way.

(Specifically: "Ant doesn't load the external library directly, it is
the loaded class that does so. In the case of |<junit>| it is the task
implementation itself." doesn't make a lot of sense to me.)

So... any ideas?

I tried running ant with -debug turned on and didn't notice anything
obvious. I think my next step is to take that horrible mess of a
project.classpath and turn it into a collection of seperate
<pathelement> tags and then find out if any of these can't be found but
I would welcome any help that anyone can give me.

Kind regards,

- alasdair

Alasdair Young
Vigilos Inc.

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

View raw message