jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicholas Lesiecki" <n...@eblox.com>
Subject RE: java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase
Date Thu, 21 Feb 2002 19:17:55 GMT
RE: java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCaseMark,

Thank you for this submission. Essentially, I'd like to integrate your
change and then re-run the unit tests against several containers (Tomcat,
Resin, Orion, etc.) to make sure that it has no unintended consequences for
the "standard" configuration.

Off hand, I think your patch will make cactus configuration substantially
more forgiving. I'm looking forward to using it myself :)

As background to this change, interested developers should check out:


(a paper by Ted Neward explaining the subtleties in the Java classloader
model: a worthwhile read for anyone doing web app development).

Thanks for contributing!


Nicholas Lesiecki
  -----Original Message-----
  From: Volkmann, Mark [mailto:Mark.Volkmann@AGEDWARDS.com]
  Sent: Thursday, February 21, 2002 7:12 AM
  To: 'Fred Loney'; 'cactus-user@jakarta.apache.org'
  Subject: RE: java.lang.NoClassDefFoundError:

  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:

    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.


    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.lang.ClassLoader.loadClass(ClassLoader.java:297)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:120)

  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.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message