----- Original Message -----
From: "Jari Worsley" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 04, 2001 2:54 PM
Subject: Re: [cactus]Bug with logging and JSP testing


> Jari Worsley wrote:
> >
> > I am getting an error trying to use the latest build with the
> > JspTestcaller class.
> >
> > If i run some tests that use ServletTestCase first, then  run a
> > JspTestCase it doesn't repeat.
> >
>
> ok,
>
> after actually looking at the code, the ServletRedirector has this in:
>     /**
>      * Initialize the logging subsystem so that it can get it's
> configuration
>      * details from the correct properties file. Initialization is done
> here
>      * as this servlet is the first point of entry to the server code.
>      */
>     static {
>         LogService.getInstance().init("/log_server.properties");
>     }
>
> the problem is that to use JspTestCase you call the redirector.jsp page,
> meaning this static code is never called, as the ServletRedirector
> hasn't been loaded by the ClassLoader yet. That's why JspTestCases will
> work if you call a ServletTestCase first.
>

yes

> Adding :
>
>
org.apache.commons.cactus.util.log.LogService.getInstance().init("/log_serve
r.properties");
> to the redirector.jsp page fixes it.
>

hum ... if you put this in redirector.jsp then it gets called every time ...
That's why I preferred to put as a static block in JspTestCaller.java. By
the way, is there any way of putting static java code in a JSP page ?

> not sure if that's the best place to apply the fix, or if it should go
> somewhere else for use by both jsp and servlet tests.
>

it is if you want to be able to put log statements either in JspTestCaller
or in ServletTestCaller.

> Jari
-Vincent

Reply via email to