Thanks for the reply, Chris.

We do several things during context initialization with the
ServletContextListener hook. The contextInitialized method may not
complete for various reasons, sometimes with checked exceptions and
sometimes with unchecked exceptions. We just let Tomcat/JVM handle the
unchecked exceptions. We do not have any custom filter that checks the
"health of the context" at the moment. What I'm looking for is a way
to override the error pages of Tomcat at the global level (not
application/context specific), but container specific. For example, if
I can define an error page/template in server.xml or something like
that. Just checking to see if there is way to override this in Tomcat.
In the mean time, I will see if I can have a "catchall" during context
initialization and see how various pieces (individual URLs) of the
application react when the context really failed to initialize.

Sai Pullabhotla

On Tue, May 24, 2011 at 8:10 AM, chris derham <ch...@derham.me.uk> wrote:
> On Tue, May 24, 2011 at 9:59 AM, Sai Pullabhotla <
> sai.pullabho...@jmethods.com> wrote:
>
>> I've a web application with two contexts "ROOT" and "mycontext". Both
>> contexts have custom error pages defined in the web.xml and everything
>> works as expected in most cases. The only problem is that if my
>> context, mycontext, fails to initialize (e.g. database is
>> unavailable), and if some one tries to access a page from context1,
>> Tomcat falls back to the default error pages. Is there a way to
>> override the default error pages in this case?
>>
>> If the application throws an exception during context initialization, then
> the web app is not loaded. Hence your custom error pages won't be defined.
> The logical choice would be to stop the app from failing during context
> initialization - well at least stop it from throwing an exception. Then the
> app would still load into tomcat, and so the custom pages would still work.
> Can you perform the initialization using lazy instantiation?
>
> I guess the question is what do you want to happen when db fails during
> context initialization? You could have a flag and a filter that redirects to
> a "all broken" jsp if the app can't connect to the db?
>
> HTH
>
> Chris
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to