jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Lenz <cml...@gmx.de>
Subject Re: java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase problem again.
Date Thu, 24 Apr 2003 08:05:44 GMT
Another comment below:

karthik Guru wrote:
> I understand it is a very common problem reported here. I got cactus to 
> work with our product and now while setting it up for the other, i ran 
> into this issue.
> 
> this is how my war file is structured:
> 
> WEB-INF/lib:
>   cactus.jar
>   aspectjrt.jar
>   commons-logging1.0.jar
>   httpclient.jar
>   testinfra.jar
>   tests.jar
> 
> tests.jar has all the tests.
> testinfra.jar has the BaseTestCase (from which all the tests inherit.) + 
> some utilities
> There is no Class-Path attribute defined in testinfra.jar and tests.jar 
> manifests. I assume that everything will get picked up from the 
> WEB-INF/lib folder.
> 
> I get the NoClassDefFoundError when i run my tests.
> Any idea as to why the cactus.jar is not getting picked up from web-inf\lib.
> 
> java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase
> at java.lang.ClassLoader.defineClass0(Native Method)

The NoClassDefFoundError does *not* mean that cactus.jar isn't getting 
picked up. It usually indicates that another class (your test case, for 
example) is trying to load a Cactus class, but is failing because of 
classloader hierarchy problems.

Double-check that you're test case is loaded by the same classloader 
that cactus.jar is loaded by.

When I last had this problem, it was because I accidentially had the 
test classes both in a EJB jar and in the web-app. The server found the 
test classes in the EJB jar first, and tried to load them on request. 
But then, because cactus.jar was loaded by a class loader further down 
in the hierarchy, I'd get a NoClassDefFoundError.

Hope this helps. Although the problem is hard to track down, you usually 
feel a bit stupid when you eventually find the root cause ;-)

-- 
Christopher Lenz
/=/ cmlenz at gmx.de


Mime
View raw message