I have done some researching and was able to reproduce the problem by
removing junit.jar from my server side classpath .... However I did not
understand why it would not print the error message I had put in my code and
why the error would be on the call "ServletTestCaller caller = new
ServletTestCaller();" when ServletTestCaller does not make use of JUnit ...
!!
I think I have now understood ... Something a bit tricky it seems ...
What I understand is that although ServletTestCaller does not make use of
junit at all, it is loaded by the Tomcat WebappClassLoader. And it seems
that this loader actually makes a check at that point to verify that all
classes within it can be loaded ... So it will find that your test class
which makes use of Junit cannot be loaded ... This is the only way I can
understand it ... (I'll need to put the question to the Tomcat team or look
at the Tomcat code to verify that).
Here is the stack trace resulting from :
ServletTestCaller caller = null;
try {
caller = new ServletTestCaller();
} catch (Throwable e) {
logger.debug("an error", e);
}
java.lang.NoClassDefFoundError: junit/framework/TestCase
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:486)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:111)
at
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLo
ader.java:1475)
at
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.jav
a:836)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1215)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
a:1098)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at
org.apache.commons.cactus.server.ServletTestRedirector.doPost(ServletTestRed
irector.java:143)
This is a very strange behaviour in my opinion ...
I'll update the code to catch correctly the error and report it nicely ...
Thanks
-Vincent
----- Original Message -----
From: "Jim Cheesman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 12:46 PM
Subject: Re: FileNotFoundException: ServletRedirector
> At 06:43 PM 24/07/01, you wrote:
> >Hi Jim,
> >
> >Hey, you are scaring me, all 3 of you saying that you're having problems
> >with Cactus ! :-)
> >So I tested it on my machine. I tested with the following confs:
> >
> >- win 2K
> >- junit 3.7
> >- tomcat4.0b5 and tomcat4.0b6
> >- cactus 1.1 downloaded from the web site
> >- jdk 1.3
> >
> >... and it works like a charm ... I have used the sample as provided,
using
> >the provided Ant script.
> >
> >So it may be that you all have a problem in your classpath or in the war
> >that you use.
> >Could you :
> >1/ Tell me what you have in your war in term of jars and classes
>
>
> Not a war - it's expanded.
> In WEB-INF/lib:
> commons-cactus.jar
> commons-cactus-ant.jar
> xerces.jar
> outputs.jar (which contains my classes etc.)
>
>
>
>
>
>
> >2/ Give me the command line that you use to start Cactus
>
> It's the main of a junit test case, using the text ui:
> java sinfo.jsp.utils.TestGenerateJspServlet
> I've just retested using ant to run the tests, and the failure is the
same.
>
>
> The test case is (irrelevant bits snipped):
>
> public class TestGenerateJspServlet extends ServletTestCase {
> String testURL = "http://pc_ojcheesman:8080/sinfo/GenerateJspServlet";
> String testQueryString =
> "pgcode=Tst&lang=ENG&discipline=BV&TRN_SPORT=BV&TRN_VENUE=BVO&TRN_ID=";
> String testContents = "\n<html><body>test</body></html>";
>
>
> public static void main(String[] theArgs) {
> junit.textui.TestRunner.main(new
> String[]{TestGenerateJspServlet.class.getName()});
> }
>
> public static Test suite() {
> return new TestSuite(TestGenerateJspServlet.class);
> }
>
> public void testResponse() throws Exception {
> testQueryString = testQueryString + (int) (Math.random() * 10000);
>
> WebConversation conversation = new WebConversation();
> WebRequest request = new GetMethodWebRequest(testURL + "?" +
> testQueryString);
>
> WebResponse response = conversation.getResponse(request);
> String pageContents = response.getText();
> assertEquals("The contents are not the same ", testContents.trim(),
> pageContents.trim());
> }
>
>
>
> Tomcat is up and running fine, (4.0b6), the sun is shining and all else is
> well in the world.
> Typing in http//127.0.0.1:8080/sinfo/ServletRedirector I get a
> ServletException complaining about missing parameters.
>
>
>
>
> >... so that I can try to reproduce or understand the problem. I really
need
> >to finish the auto-diagnosis tool that I wanted to write ... :-)
> >Can you also send me the logs client and server (cactus_client.log and
> >cactus_server.log) (you need to put log4j.jar in both your client JVM
> >classpath and in your WEB-INF/lib dir of your webapp.
>
> Downloading now... (Which is no doubt something that I should have got
> round to doing long ago ;))
>
>
> cactus_server.log:
> 0 [HttpProcessor[8080][4]] DEBUG server.ServletTestRedirector -
>doPost(...)
> 10 [HttpProcessor[8080][4]] DEBUG server.ServletTestRedirector - Default
> buffer size = 1024
> 10 [HttpProcessor[8080][4]] DEBUG server.ServletTestRedirector - Service
> called = CALL_TEST
>
> cactus_client.log doesn't seem to exist anywhere on my system...
>
>
>
>
>
>
>
>
> --
>
> * Jim Cheesman *
> Trabajo:
> [EMAIL PROTECTED] - (34)(91) 724 9200 x 2360
> I keep telling
> myself that I am a pathological
> liar, but I am not sure if
> I believe it.
>
>
>