Bug 33440 - A class needed by class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found: junit/framework/Test
Summary: A class needed by class org.apache.tools.ant.taskdefs.optional.junit.JUnitTas...
Status: RESOLVED DUPLICATE of bug 38799
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: nightly
Hardware: PC Linux
: P2 major (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-08 10:13 UTC by Michal Jacykiewicz
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments
File build.xml which fails. (3.07 KB, text/plain)
2005-02-08 10:13 UTC, Michal Jacykiewicz
Details
Output from the ant -v command. (7.76 KB, text/plain)
2005-02-08 10:14 UTC, Michal Jacykiewicz
Details
Output of the ant -diagnostics command. (7.33 KB, text/plain)
2005-02-08 10:14 UTC, Michal Jacykiewicz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Jacykiewicz 2005-02-08 10:13:02 UTC
Please find attached files: build.xml, output of ant -v and ant -diagnostics.
If I am doing something wrong, please change this issue to request for 
enhancement to the documentation (e.g. taskdef, classpath, junit, optional 
tassks).
This issue is releated to bugid#33428.
Comment 1 Michal Jacykiewicz 2005-02-08 10:13:32 UTC
Created attachment 14205 [details]
File build.xml which fails.
Comment 2 Michal Jacykiewicz 2005-02-08 10:14:04 UTC
Created attachment 14206 [details]
Output from the ant -v command.
Comment 3 Michal Jacykiewicz 2005-02-08 10:14:38 UTC
Created attachment 14207 [details]
Output of the ant -diagnostics command.
Comment 4 Jan Mat 2005-02-08 10:40:45 UTC
External libraries are not shipped with Ant.
See http://ant.apache.org/manual/install.html#librarydependencies
Comment 5 Michal Jacykiewicz 2005-02-08 10:46:17 UTC
I know that. I've got Junit installed.

jacykm@leopard:/tmp/antjunit> ls -l $JUNIT_HOME/junit.jar
-rw-r--r--    1 jacykm   ndseng     121070 Sep  4  2002 /phoebe_home/jacykm/bin/
tools/junit3.8.1/junit.jar
jacykm@leopard:/tmp/antjunit>

Comment 6 Jan Mat 2005-02-08 10:49:13 UTC
That directory is not loaded by Ant.
1: place junit.jar in ${user.home}/.ant/lib
2: load that jar using -lib option

Comment 7 Michal Jacykiewicz 2005-02-08 11:02:27 UTC
Why it isn't?
In that case that <classpath> within <taskdef> means?

<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.
JUnitTask">
    <classpath refid="runtimelibs"/>
</taskdef>

Where
    <path id="runtimelibs">
        <pathelement location="${junit-dir}/junit.jar"/>
    </path>
Comment 8 Steve Loughran 2005-02-08 12:57:03 UTC
Classloaders, that's why. Ant has a boot classloader (ant-launcher) that then
loads everything else, including ~/.ant/lib and anything with -lib on the
commandline. And the classpath, unless you say -noclasspath. ant-junit.jar is
loaded in that main classloader, so cannot see junit.jar. Even your
redeclaration wont help, as the one in the main classloader gets in there first.

you need to remove ant-junit.jar from your main ant library and include in the
taskpath for the redeclaration, so it shares the classloader with junit. Or pass
in the dir containing junit.jar as a -lib options.
Comment 9 Stefan Bodewig 2005-03-11 16:22:40 UTC

*** This bug has been marked as a duplicate of 6606 ***
Comment 10 Jesse Glick 2006-02-27 20:44:08 UTC
More precise duplicate.
Comment 11 Jesse Glick 2006-02-27 20:44:28 UTC

*** This bug has been marked as a duplicate of 38799 ***