File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Terminate a web application.

 
Wes Hughes
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way to terminate a web application without calling System.exit(). Basically, if there are some invalid properties/etc during initialization of the web app, we would like to force the application to shut down or not run. Calling System.exit is obviously risky in a shared container.

Thx in advance.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The servlet's init function can throw an exception to indicate that it cannot be loaded. Check the docs.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Calling System.exit is obviously risky in a shared container.


"risky"? Try completely idiotic.

Throw an UnavailableException. The container will catch it and take the servlet out of service.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of System.exit() some people have found handgranades and RPGs to be quite effective.
Minor problem is the refusal of the application or indeed the server to start afterwards

Simplest option is to reload the web application using your server's administration console or whatever it uses for the task.
 
Ivan Jouikov
Ranch Hand
Posts: 269
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
go to your tomcat page (localhost:8080), click on Manager, type in your username and password (located in $CATALINA_HOME/conf/users.xml) for admin. There you will see list of application. You can stop, start, restart, and undeploy them. What you're looking for is stop.
 
Wes Hughes
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for all the answers but I'm really looking for programmatic solutions along the line of the first two.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic