jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Volkmann, Mark" <Mark.Volkm...@AGEDWARDS.com>
Subject RE: java.lang.NoClassDefFoundError: org/apache/cactus/ServletTest Case
Date Thu, 21 Feb 2002 14:12:14 GMT
We did resolve the problem, but the solution isn't pretty. We had to patch
Cactus to get it to work. I've attached a class we added. We replaced all
calls to Class.forName in the Cactus source with calls to
ClassLoaderHelper.forName. This allows classes in your web app., such as
your unit test code, to find classes in your server classpath, such as
Cactus and Log4J classes. We think the problem has something to do with
using Log4J in our application. We put log4j.jar in our server classpath and
this seems to be a problem for Cactus without the patch. I've also attached
our custom cactus.jar file that contains these changes.

All you need to do to try it is put all the JARs cactus needs
(aspectjrt.jar, cactus.jar, httpunit.jar, junit.jar and log4j.jar) in your
server classpath instead of your web app. Another advantage to this approach
is that you don't have to include all those JARs in every web application.
That's a big plus for us because we are testing around 20 web apps. Perhaps
this change should become part of the normal Cactus codebase!

If this is a bad idea, I'd like to hear why.

 <<ClassLoaderHelper.java>>  <<cactus.jar>> 

> -----Original Message-----
> From:	Fred Loney [SMTP:loney@spiritedsw.com]
> Sent:	Wednesday, February 20, 2002 9:23 PM
> To:	Volkmann, Mark
> Subject:	java.lang.NoClassDefFoundError:
> org/apache/cactus/ServletTestCase
> Were you able to resolve the problem? I have the same situation and
> would appreciate any advice on resolution. Classloaders are truly the
> bane of webapp development.
> Thanks.
> ----
> Mark Volkmann wrote:
> Here's part of the stack trace I'm getting.
> cactus.jar, junit.jar and aspectjrt.jar are in the WEB-INF/lib of the
> file of my web application.
> They are not available through my CLASSPATH.
> How could it find AbstractTestCaller, but not find ServletTestCase?
> java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase
> at java.lang.ClassLoader.defineClass0(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
> at
> weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericCla
> ssLo
> ader.java:339)
> at
> weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoa
> der.
> java:156)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
> at
> weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAware
> Clas
> sLoader.java:43)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:120)
> at
> org.apache.cactus.server.AbstractTestCaller.getTestClassClass(AbstractTe
> stCa
> ller.java:326)

WARNING:  All e-mail sent to and from this address will be received or
otherwise recorded by the A.G. Edwards corporate e-mail system and is
subject to archival, monitoring or review by, and/or disclosure to,
someone other than the recipient.

View raw message