java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase

By W.ZH Dec 28 2010

 

Issue:

When I try to run my test case through servlet of ServletTestRunner from the cactus’s war file. i face this exception:

java.lang.NoClassDefFoundError: org/apache/cactus/ServletTestCase

Reason:

In fact it is very hard to find the reason fro this kind of things. We should explain how this cactus runs by class loader, then you can know what may cause this:

WEB-INF/classes CL --> WEB-INF/lib CL --> system CL

You see, the cactus WEB-INF/classes in fact should contain your test cases classes, those u write to inherit the ServletTestCase.

and all cactus related jar should be put into the WEB-INF/lib.

to make your test cases can run,you normally also has alot other jars put into the ear file top layer, bu they are outside the WEB-INF.

So there are three place u need to check:

1. WEB-INF/classes has all the test cases class.

2. WEB-INF/lib has all the test case support jar lib files.

3. Your top layer(outside the WEB-INF), do not has any test cases class. You may need to unzip all your jars to look for them.

What error I made is N0. 3!

like this :

http://mail-archives.apache.org/mod_mbox/jakarta-cactus-user/200304.mbox/%3C3EA79AD8.2080308@gmx.de%3E

Solution:

After u find the reason, I think you know how to fix this error!

Ref:

http://mail-archives.apache.org/mod_mbox/jakarta-cactus-dev/200202.mbox/%3C002901c1bb48$0332b9e0$3b22e40c@spiritedsw.com%3E

Advertisements