wood burning stoves
The moose likes Servlets and the fly likes Terminate a web application. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Terminate a web application." Watch "Terminate a web application." New topic

Terminate a web application.

Wes Hughes
Ranch Hand

Joined: Jul 29, 2002
Posts: 31
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

Joined: May 29, 2003
Posts: 1258
The servlet's init function can throw an exception to indicate that it cannot be loaded. Check the docs.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

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.

[Asking smart questions] [About Bear] [Books by Bear]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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

Joined: Jul 22, 2003
Posts: 269
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

Joined: Jul 29, 2002
Posts: 31
Thanks for all the answers but I'm really looking for programmatic solutions along the line of the first two.
I agree. Here's the link: http://aspose.com/file-tools
subject: Terminate a web application.
It's not a secret anymore!