Search code examples
antdbunit

ANT is failing to find org.dbunit.ant.DbUnitTask


So I'm writing a ant build file to run some tests, and I use the following line without any issue for MXUnit:

<taskdef name="mxunittask" classname="org.mxunit.ant.MXUnitAntTask" classpath="../mxunit/ant/lib/mxunit-ant.jar"/>

But when I download dbunit-2.4.8.jar from http://sourceforge.net/projects/dbunit/files/ and put it in the same directory as mxunit-ant.jar, then added the following line to the ANT build file:

<taskdef name="dbunit" classname="org.dbunit.ant.DbUnitTask" classpath="../mxunit/ant/lib/dbunit-2.4.8.jar"/>

For which I see a warning in Eclipse that says:

taskdef A class needed by class org.dbunit.ant.DbUnitTask cannot be found: org/slf4j/LoggerFactory

When I extract the jar file it does have the org.dbunit.ant.DbUnitTask class.. so I'm very confused as to what ANT is complaining about.. any idea what the issue is?


Solution

  • It looks like you need to make sure all the dependencies of DbUnit are satisfied, as well as installing the dbunit-2.4.8.jar.

    The specific error you quote with class org/slf4j/LoggerFactory not being found suggests that you don't have the SLF4J classes needed. (Probably the latest version of slf4j-api.jar is needed there.)