If I have a servlet which fails during init() for whatever reason -
the example below takes a null pointer....

public class MyServlet extends HttpServlet
{
        private static final long serialVersionUID = 7997991143724219371L;

        @Override
        public void destroy()
        {
                //do stuff....
                super.destroy();
        }

        @Override
        public void init() throws ServletException
        {
                try
                {
                        String a = null;
                        a.toString();
                }
                catch (Exception e)
                {
                        System.err.println("Startup error - cancelling 
startup." +  e);
                        try
                        {
                                destroy();
                        }
                        catch (Exception e1)
                        {
                                //noop
                        }
                        throw new ServletException("Startup failing due to 
unexpected error: " + e);
                }
        }
}


How can I make tomcat cancel the deployment of the entire war file
that this servlet was distributed with?

I thought that throwing a ServletException back up to Tomcat would
make the webapp unavailable - but Tomcat continues to serve pages from
this webapp even though the startup failed.  That doesn't seem like
correct behavior... am I missing a setting somewhere?

Thanks,

Dan

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

Reply via email to