Bug 33440

Summary: A class needed by class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found: junit/framework/Test
Product: Ant Reporter: Michal Jacykiewicz <mjac>
Component: Optional TasksAssignee: Ant Notifications List <notifications>
Status: RESOLVED DUPLICATE    
Severity: major    
Priority: P2    
Version: nightly   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Attachments: File build.xml which fails.
Output from the ant -v command.
Output of the ant -diagnostics command.

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 ***