Just a guess:

You defined a servlet in your web.xml, but called it using a
/servlet/<servlet-class-name> style url...
The /servlet interceptor can't know that you already used that class to define a
servlet and initialises its own copy...
This would also explain why there are no init-parameters available in the "second"
call: the /servlet interceptor has no access to the web.xml.

Try adding a instance variable that counts the number of init() calls.  This should
prove two different instances of your servlet are created.

If in web.xml, you define the servlet, define a url-mapping and then access the
servlet through that mapping there should be only one instance that is initialised
exactly once.

Luc Vanlerberghe

"Stein M. Eliassen" wrote:

> Hi,
>
> I think there is a problem with the getInitParameter in 3.2.1.
>
> When a servlet is defined with <load-on-startup>1</load-on-startup> in
> WEB-INF/web.xml the init()-method gets called twice.
>
> First time, as expected, when the servlet-engine fires-up.
>
> Everthing is swell with the getInitParameter-calls, that is, the init-params are
> valid.
>
> The "second time" init() is called is when the servlet is getting a request for
> the first time, but this time the getInitParameter just return nulls so init()
> exits with an exception.
>
> I say "second time" because tomcat is trying to create a new instance of the
> servlet.
>
> And when I shut-down tomcat I can see the destroy-method gets called for the
> rightly created instance.
>
> When I remove the <load-on-startup>-parameter from web.xml the getInitParameter
> also returns null in the init-method.
>
> This happens both in VAJ 3.02 on linux(jdk 1.1.7) and IBM JDK 1.3, also on
> linux.
>
> ROOT-context or not doesn't seem to matter.
>
> I searched the mailing-lists, but couldn't determine if this was fixed or of any
> workarounds that worked.
>
> Any comments on this?
>
> Regards
> Stein M. Eliassen
> System Developer - KPNQwest Norway AS
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to