You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Renee Petris <re...@loudeye.com> on 2000/10/02 08:01:04 UTC

Getting tomcat to instantiate an instance of a servlet after fail ed initialization attemp

I have a servlet that attempts to connect to a remote service during the
init method. If the remote service is unavailable, the servlet throws a
ServletException. If I then fix the problem, i.e. make the service
available, and retry the servlet, Tomcat doesn't try to re-instantiate the
servlet. I've checked this by putting a println statement in the init
method. I have to restart Tomcat to get the servlet to start. According to
the servlet spec, the servlet container may instantiate a new instance at
any time after a failed initialization attempt unless the servlet threw an
UnavailableException. Is there a way to make tomcat attempt to
re-instantiate the servlet?

Renée Petris
Overseer of the Execution
Loudeye Technologies
renee@loudeye.com
414 Olive Way, Suite 300
Seattle, WA 98101
206-832-4500 phone
206-832-4475 fax 

 

Re: Getting tomcat to instantiate an instance of a servlet after failed initialization attemp

Posted by Steve Weiss <sw...@aamc.org>.
> Renee Petris wrote:
> 
> I have a servlet that attempts to connect to a remote service during
> the init method. If the remote service is unavailable, the servlet
> throws a ServletException. If I then fix the problem, i.e. make the
> service available, and retry the servlet, Tomcat doesn't try to
> re-instantiate the servlet. I've checked this by putting a println
> statement in the init method. I have to restart Tomcat to get the
> servlet to start. According to the servlet spec, the servlet container
> may instantiate a new instance at any time after a failed
> initialization attempt unless the servlet threw an
> UnavailableException. Is there a way to make tomcat attempt to
> re-instantiate the servlet?
> 

I don't know if what you're asking is possible, but you could accomplish
what you want by starting up a background thread in your servlet's
init() method which just keeps trying to connect to the remote object.

-Steve
-- 
Steve Weiss      Association of American Medical Colleges
(202)828-0428    mailto:sweiss@aamc.org    http://www.aamc.org