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 Tasks | Assignee: | 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
Created attachment 14205 [details]
File build.xml which fails.
Created attachment 14206 [details]
Output from the ant -v command.
Created attachment 14207 [details]
Output of the ant -diagnostics command.
External libraries are not shipped with Ant. See http://ant.apache.org/manual/install.html#librarydependencies 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> That directory is not loaded by Ant. 1: place junit.jar in ${user.home}/.ant/lib 2: load that jar using -lib option 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> 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. *** This bug has been marked as a duplicate of 6606 *** More precise duplicate. *** This bug has been marked as a duplicate of 38799 *** |