Ich bekomme NoClassDefFoundError, wenn ich über Ant läuft, aber es funktioniert, wenn ich die App in Tomcat entfaltete.NoClassDefFoundError bei der Ausführung von Test über Ant, aber Arbeit bei der Bereitstellung in Tomcat
rufe ich es
ant test
Exception
java.lang.NoClassDefFoundError: org/apache/commons/dbcp2/BasicDataSource
at com.x.ws.repo.DatabaseConnection.<init>(Unknown Source)
at com.x.ws.repo.DatabaseConnection.getSynchronizedInstance(Unknown Source)
at com.x.ws.repo.DatabaseConnection.getInstance(Unknown Source)
at com.x.ws.repo.Foo.<init>(Unknown Source)
at com.x.ws.repo.FooTest.setUp(Unknown Source)
Ant-Skript
mit
<path id="classpath.test">
<pathelement location="WebContent/WEB-INF/lib/junit-4.11.jar"/>
<pathelement location="WebContent/WEB-INF/lib/hamcrest-all-1.3.jar"/>
<pathelement location="WebContent/WEB-INF/lib/java-json.jar"/>
<pathelement location="${main.build.dir}"/>
</path>
<target name="test-compile" depends="compile">
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}">
<classpath refid="classpath.test"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="test" depends="test-compile">
<junit printsummary="yes" haltonfailure="no">
<classpath refid="classpath.test" />
<classpath location="${test.build.dir}" />
<formatter type="xml" />
<formatter type="plain" />
<batchtest fork="yes" todir="${reports.src.dir}">
<fileset dir="${test.src.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
</target>