Hi Marcio,
I think the reason is simply because you're missing a <classpath>
element in your <cactus> task. Indeed, you need to set the Cactus client
side classpath.
You should use something like:
<cactus
warfile="${build.dir.temp}/cactus-${war.name}"
printsummary="yes"
failureproperty="testsFailed">
<classpath>
<pathelement location="path to your cactus test sources"/>
<pathelement location="path to your runtime sources"/>
<pathelement location="path to your servlet.jar"/>
</classpath>
<containerset>
<tomcat4x dir="${tomcat.home}"
port="${tomcat.local.port}"
todir="${reports.dir.cactus.tomcat}"/>
</containerset>
<formatter type="xml"/>
<batchtest>
<fileset dir="${src.dir}">
<include name="**/cactus/*.java"/>
</fileset>
</batchtest>
</cactus>
Thanks
-Vincent
> -----Original Message-----
> From: Marcio Marchini [mailto:[EMAIL PROTECTED]
> Sent: 25 July 2003 00:09
> To: [EMAIL PROTECTED]
> Subject: ClassNotFoundException for my test class in WEB-INF/classes
>
> Hi,
>
> I know this is a problematic topic, and I read the web pages for
> dealing with classpath problems. I also browsed the list archives. The
> problem I am having is quite bizarre. My *test* class, which *is* in
my
> WAR
> file, is not being found.
>
>
> <error
> message="com.bedarra.continuousbuild.example.tests.cactus.TestHello"
>
type="java.lang.ClassNotFoundException">java.lang.ClassNotFoundException
:
> com.bedarra.continuousbuild.example.tests.cactus.TestHello
> at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:140)
> at
>
org.apache.cactus.integration.ant.CactusTask.executeInContainer(CactusTa
sk
> .j
> ava:412)
> at
>
org.apache.cactus.integration.ant.CactusTask.execute(CactusTask.java:250
)
> </error>
>
>
> If I unzip the cactified WAR (just to show the files) I get
this:
>
> Archive: build/temp/cactus-Hello-20030723.war
> creating: META-INF/
> inflating: META-INF/MANIFEST.MF
> creating: WEB-INF/
> creating: WEB-INF/classes/
> creating: WEB-INF/classes/com/
> creating: WEB-INF/classes/com/bedarra/
> creating: WEB-INF/classes/com/bedarra/continuousbuild/
> creating: WEB-INF/classes/com/bedarra/continuousbuild/example/
> creating:
WEB-INF/classes/com/bedarra/continuousbuild/example/tests/
> creating:
> WEB-INF/classes/com/bedarra/continuousbuild/example/tests/cactus/
> inflating:
> WEB-
>
INF/classes/com/bedarra/continuousbuild/example/HelloWorldServlet.class
> inflating:
> WEB-
>
INF/classes/com/bedarra/continuousbuild/example/tests/cactus/TestHello.c
> lass
> inflating: hi.jsp
> inflating: jspRedirector.jsp
> inflating: WEB-INF/web.xml
> creating: WEB-INF/lib/
> inflating: WEB-INF/lib/aspectjrt-1.0.6.jar
> inflating: WEB-INF/lib/cactus-1.5-beta1.jar
> inflating: WEB-INF/lib/commons-logging-1.0.3.jar
> inflating: WEB-INF/lib/commons-httpclient-2.0-beta2.jar
> inflating: WEB-INF/lib/junit.jar
>
>
>
> Any idea ? My Ant target looks like this:
>
> <target name="test-cactus" depends="war-cactus"
description="Runs
> Cactus tests">
> <condition property="cactus.ok">
> <and>
> <available file="${tools.jar}"/>
> <available file="${cactus.home}/lib" type="dir"/>
> </and>
> </condition>
> <fail unless="cactus.ok">Missing pre-req JAR file for
Cactus.
> Check build.properties.</fail>
> <!-- Define the Cactus tasks -->
> <path id="cactus.classpath">
> <pathelement path="${tools.jar}"/>
> <fileset dir="${cactus.home}/lib" >
> <include name="*.jar"/>
> </fileset>
> </path>
> <property name="cactus.classpath"
refid="cactus.classpath"/>
> <taskdef resource="cactus.tasks"
> classpathref="cactus.classpath"/>
>
> <cactifywar
> srcfile="${build.dir.temp}/${war.name}"
> destfile="${build.dir.temp}/cactus-${war.name}">
>
> </cactifywar>
>
> <cactus
> warfile="${build.dir.temp}/cactus-${war.name}"
> printsummary="yes"
> failureproperty="testsFailed">
>
> <containerset>
> <tomcat4x dir="${tomcat.home}"
> port="${tomcat.local.port}"
> todir="${reports.dir.cactus.tomcat}"/>
> </containerset>
> <formatter type="xml"/>
> <batchtest>
> <fileset dir="${src.dir}">
> <include name="**/cactus/*.java"/>
> </fileset>
> </batchtest>
> </cactus>
> </target>
>
>
> Anyway, this is the output from Ant:
>
>
> test-cactus:
> [cactifywar] Analyzing war:
>
C:\marcio\eclipse\ss\com.bedarra.continuousbuild.example\build\temp\Hell
o-
> 20
> 030723.war
> [cactifywar] Building war:
>
C:\marcio\eclipse\ss\com.bedarra.continuousbuild.example\build\temp\cact
us
> -H
> ello-20030723.war
> [cactus]
> -----------------------------------------------------------------
> [cactus] Running tests against Tomcat 4.1.24
> [cactus]
> -----------------------------------------------------------------
> [cactus] Deleting 16 files from
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x
> [cactus] Deleted 17 directories from
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x
> [cactus] HttpConnector Opening server socket on all host IP
> addresses
> [cactus] Starting service Tomcat-Standalone
> [cactus] Apache Tomcat/4.1.24
> [cactus] HostConfig[localhost]: Expanding web application
archive
> cactus-Hello-20030723.war
> [cactus] StandardHost[localhost]: Installing web application at
> context path /cactus-Hello-20030723 from URL
> file:C:/DOCUME~1/marcio/LOCALS~1/Temp/cactus/tomcat4x/webapps/cactus-
> Hello-2
> 0030723
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploying class
> repositories to work directory C:\Documents and Settings\marcio\Local
> Settings\Temp\cactus\tomcat4x\work\Standalone\localhost\cactus-Hello-
> 2003072
> 3
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy class
files
> /WEB-INF/classes to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\classes
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy JAR
> /WEB-INF/lib/aspectjrt-1.0.6.jar to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\lib\aspectjrt-1.0.6.jar
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy JAR
> /WEB-INF/lib/cactus-1.5-beta1.jar to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\lib\cactus-1.5-beta1.jar
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy JAR
> /WEB-INF/lib/commons-httpclient-2.0-beta2.jar to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\lib\commons-httpclient-2.0-beta2.jar
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy JAR
> /WEB-INF/lib/commons-logging-1.0.3.jar to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\lib\commons-logging-1.0.3.jar
> [cactus] WebappLoader[/cactus-Hello-20030723]: Deploy JAR
> /WEB-INF/lib/junit.jar to
> C:\DOCUME~1\marcio\LOCALS~1\Temp\cactus\tomcat4x\webapps\cactus-Hello-
> 200307
> 23\WEB-INF\lib\junit.jar
> [cactus] StandardManager[/cactus-Hello-20030723]: Seeding random
> number generator class java.security.SecureRandom
> [cactus] StandardManager[/cactus-Hello-20030723]: Seeding of
random
> number generator has been completed
> [cactus] StandardWrapper[/cactus-Hello-20030723:default]:
Loading
> container servlet default
> [cactus] StandardWrapper[/cactus-Hello-20030723:invoker]:
Loading
> container servlet invoker
> [cactus] HttpConnector[8080] Starting background thread
> [cactus] Running
> com.bedarra.continuousbuild.example.tests.cactus.TestHello
> [cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0
sec
> [cactus] TEST
> com.bedarra.continuousbuild.example.tests.cactus.TestHello FAILED
> [cactus] Stopping service Tomcat-Standalone
> [cactus] HttpConnector[8080] Stopping background thread
> [cactus] StandardHost[localhost]: Removing web application at
> context
> path /cactus-Hello-20030723
>
>
>
>
> The problem is the line:
> [cactus] TEST
> com.bedarra.continuousbuild.example.tests.cactus.TestHello FAILED
>
>
> Anyway, any idea ? Thanks,
>
> marcio
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]