I have not received any answer to my post. After I read Cactus
architecture, I am pretty sure that this problem is related to class loader.
I added one line of code as indicated below to print stack trace. The
exception is thrown from junit.framework.TestSuite(java.lang.Class). I can
get class name. But reflect can not get methods from class.
I never reach beginXXX method and test client never calls redirect
servlet. So the problem is related to class loader ore java reflect. I am
using VA 3.5.3 and cactus 1.2 or 1.3, and junit 3.7.
Your help is appreciated.
Jim
----------------------------------------------------------------------------
----------------------------------------------------------
/**
* Returns the Test corresponding to the given suite. This is
* a template method, subclasses override runFailed(),
clearStatus().
*/
public Test getTest(String suiteClassName) {
if (suiteClassName.length() <= 0) {
clearStatus();
return null;
}
Class testClass= null;
try {
testClass= loadSuiteClass(suiteClassName);
} catch (ClassNotFoundException e) {
String clazz= e.getMessage();
if (clazz == null)
clazz= suiteClassName;
runFailed("Class not found \""+clazz+"\"");
return null;
} catch(Exception e) {
runFailed("Error: "+e.toString());
return null;
}
Method suiteMethod= null;
try {
suiteMethod= testClass.getMethod(SUITE_METHODNAME,
new Class[0]);
} catch(Exception e) {
// try to extract a test suite automatically
clearStatus();
return new TestSuite(testClass);
}
Test test= null;
try {
test= (Test)suiteMethod.invoke(null, new Class[0]);
// static method
if (test == null)
return test;
}
catch (InvocationTargetException e) {
e.printStackTrace(); //********************** I
added this line to print stack trace. *************
runFailed("Failed to invoke suite():" +
e.getTargetException().toString());
return null;
}
catch (IllegalAccessException e) {
runFailed("Failed to invoke suite():" +
e.toString());
return null;
}
clearStatus();
return test;
}
----------------------------------------------------------------------------
-------
> -----Original Message-----
> From: Xie, Jinpeng
> Sent: Tuesday, July 30, 2002 2:49 PM
> To: '[EMAIL PROTECTED]'
> Subject: How to run Cactus in VA 3.5.3
>
> I followed the instruction in 'HOW-TO'. Once I run
> org.apache.cactus.sample.TestSampleServlet from VA, I got the following
> error:
>
>
> ava.lang.reflect.InvocationTargetException: java.lang.NoClassDefFoundError
> java.lang.Throwable()
> java.lang.Error()
> java.lang.LinkageError()
> java.lang.NoClassDefFoundError()
> java.lang.reflect.Method [] java.lang.Class.getMethods0(int)
> java.lang.reflect.Method [] java.lang.Class.getDeclaredMethods()
> junit.framework.TestSuite(java.lang.Class)
> junit.framework.Test
> org.apache.cactus.sample.TestSampleServlet.suite()
> java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object,
> java.lang.Object [])
> junit.framework.Test
> junit.runner.BaseTestRunner.getTest(java.lang.String)
> void junit.awtui.TestRunner.runSuite()
> void junit.awtui.TestRunner.start(java.lang.String [])
> void junit.ui.TestRunner.main(java.lang.String [])
> void
> org.apache.cactus.sample.TestSampleServlet.main(java.lang.String [])
>
>
> I checked all classes that are in classpath. By the way, how do I run test
> cases in Cactus? from web url or from main method?
>
>
> Jim
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>