How to fix this ANT built problem for Junit
文章来源: SSH2007-10-09 01:17:32

build.xml:35: taskdef A class needed by class org.apache.tools.ant.taskdefs.optional.junit.JUnitTask cannot be found; junit/framework/Test

Welcome to the wonderful world of plug-and-fail software. As part of the build process, Ant wants to run some JUnit tests. The rather cryptic message shown above is its way of saying that it can't find the Ant plugin (not Eclipse plugin---Ant plugin) that it needs to do this. JUnit is there, but we need to tell Ant how to find it.

So, go to Window... Preferences... Ant... Runtime, select Ant Home Entries, select "Add JARs", navigate to lib/junit.jar, and click "OK". (I got a warning about Ant not being able to find tools.jar when I did this; I ignored it.) Once that's done, go back to the Ant view inside Eclipse, right click in the pane, and select "Refresh Buildfiles". If all has gone well, the error marker disappears.

probably a problem will occur .for example:java.lang.NoClassDefFoundError: antlr/Tool do under this line. you can concrect it;

copy lib/antlr-*.jar and lib/junit-*.jar in to your local ant distribution and then you can use "pure" ant
OR (which is what i recommend)
you use build.bat/sh which runs with just the libraries distributed with hibernate.