I'll tell you what, if you can tell me how to prevent my users (who have full control over the application / installation / hardware where this is running) from being able to shoot themselves in the foot and do something that causes my app to fail - I'll buy you a case of beer and not worry about this.
Until then, my servlet needs to do system checks - and if something is wrong, it needs to not deploy. Thats the bit I haven't yet figured out... How do I get tomcat to disable the entire context, when I detect that something is broken during startup? And ideally, redirect the users to an error screen that tells them that it's broken.. Thanks, Dan On Thu, Nov 12, 2009 at 11:42 AM, Joseph Morgan <joseph.mor...@ignitesales.com> wrote: > Dan, > > Pardon my advice, but... this sounds like a programming/config/illegal > state error that shouldn't make it to production. > > Of course, you could simply add instrumentation to the system to detect > that this servlet didn't do its thing, and route every request to a > holding page. > > Joe > > -----Original Message----- > From: Dan Armbrust [mailto:daniel.armbrust.l...@gmail.com] > Sent: Thursday, November 12, 2009 10:48 AM > To: Tomcat Users List > Subject: How to cancel a servlet startup? > > 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 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org