tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: ServletContextListener fails - how to make app unavailable?
Date Thu, 11 Sep 2003 16:55:24 GMT

Howdy,
The general answer for cases like this is wrap the exception in a
RuntimeException or it's subclass.  So,

... contextInitialized(ServletContextEvent sce) {
  try {
    ...
  } catch (Exception e) {
    // Make tomcat mark this context as unavailable
    throw new RuntimeException(e);
  }
}

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Sasha Borodin [mailto:sasha@whoissasha.com]
>Sent: Thursday, September 11, 2003 12:52 PM
>To: Tomcat Users List
>Subject: ServletContextListener fails - how to make app unavailable?
>
>I've tried searching for this issue in the tomcat-user archives; I
found
>general theory but not how to implement it.  Specifically:
>
>If there's a problem within contextIntitialized(), I would want the app
to
>return HTTP 500 or something.  But the ServletContextListener interface
>does
>not declare any Exceptions thrown.  Thus I can't declare any in my
>subclass.
>Yet if I try to just catch an Exception, log, and rethrow a general
>ServletException, I can't compile cause ("must handle or declare...").
>
>So how do I notify Tomcat that there's a problem, and that the context
>should be made unavailable?
>
>Thanks,
>
>-Sasha
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org




This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


Mime
View raw message