You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by ki...@wipro.com on 2006/02/07 10:21:17 UTC

Can we stop tomcat using System.exit(int)

Hi,

My web application requires database pool connection while startup, when
it fails for any reason I need to stop the tomcat server as well.
I have used System.exit(int); int here I tried with Zero and non-zero
value.

The result is tomcat gets hung.

I understand it has to do with Java rather than Tomcat, however I'm
looking for a suggestion to stop tomcat in a way similar to the above.

I have learnt to stop tomcat
a) programmatically using Bootstrap classes, (stops successfully only if
you start programmatically)
b) by invoking shutdown.sh
c) by connecting to the server at port 8005, and send the shutdown
string.

All the above methods have yielded the same result, moreover it would
make my application coded specific to tomcat or Linux;

I have also googled with the phrase "~tomcat crash", "stop ~tomcat",
"system.exit ~tomcat", ""system.exit ~jvm""; to at least find out that
the task cannot be done, however it helped me a little.

Here are the versions of server, os and java I'm using.
Tomcat: 5.x
OS : Red Hat Enterprise Linux AS 3.0
Java: 1.5

Can somebody help me regarding the same.

Regards,
Kiran Tadepalli




The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

Re: Can we stop tomcat using System.exit(int)

Posted by David Delbecq <de...@oma.be>.
Just my 2 cents,
Have you tried to set priviledged to true in webapp context?
Also you may need to play a bit with the security manager as J2EE specs
does not endorse the use of System.exit in a webapplication.

kiran.tadepalli@wipro.com a écrit :

>Hi,
>
>My web application requires database pool connection while startup, when
>it fails for any reason I need to stop the tomcat server as well.
>I have used System.exit(int); int here I tried with Zero and non-zero
>value.
>
>The result is tomcat gets hung.
>
>I understand it has to do with Java rather than Tomcat, however I'm
>looking for a suggestion to stop tomcat in a way similar to the above.
>
>I have learnt to stop tomcat
>a) programmatically using Bootstrap classes, (stops successfully only if
>you start programmatically)
>b) by invoking shutdown.sh
>c) by connecting to the server at port 8005, and send the shutdown
>string.
>
>All the above methods have yielded the same result, moreover it would
>make my application coded specific to tomcat or Linux;
>
>I have also googled with the phrase "~tomcat crash", "stop ~tomcat",
>"system.exit ~tomcat", ""system.exit ~jvm""; to at least find out that
>the task cannot be done, however it helped me a little.
>
>Here are the versions of server, os and java I'm using.
>Tomcat: 5.x
>OS : Red Hat Enterprise Linux AS 3.0
>Java: 1.5
>
>Can somebody help me regarding the same.
>
>Regards,
>Kiran Tadepalli
>
>
>
>
>The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
>WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
>www.wipro.com
>  
>


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


Re: Can we stop tomcat using System.exit(int)

Posted by Mike Sabroff <mi...@cygnusb2b.com>.
when you call System.exit(), you shut down the jvm. It is no wonder that 
tomcat gets hung.
you don't want to make your code specific to tomcat, but yet you want to 
shut tomcat down??
write a method that does a system call, "kill -9 pid" catalina.pid is a 
file containing the pid of the tomcat instance (found in CATALINA_HOME 
or wherever your environment is set to put in. If you switch servlet 
engines, this will still work with minor modifications. crude, but so is 
System.exit().

kiran.tadepalli@wipro.com wrote:
> Hi,
>
> My web application requires database pool connection while startup, when
> it fails for any reason I need to stop the tomcat server as well.
> I have used System.exit(int); int here I tried with Zero and non-zero
> value.
>
> The result is tomcat gets hung.
>
> I understand it has to do with Java rather than Tomcat, however I'm
> looking for a suggestion to stop tomcat in a way similar to the above.
>
> I have learnt to stop tomcat
> a) programmatically using Bootstrap classes, (stops successfully only if
> you start programmatically)
> b) by invoking shutdown.sh
> c) by connecting to the server at port 8005, and send the shutdown
> string.
>
> All the above methods have yielded the same result, moreover it would
> make my application coded specific to tomcat or Linux;
>
> I have also googled with the phrase "~tomcat crash", "stop ~tomcat",
> "system.exit ~tomcat", ""system.exit ~jvm""; to at least find out that
> the task cannot be done, however it helped me a little.
>
> Here are the versions of server, os and java I'm using.
> Tomcat: 5.x
> OS : Red Hat Enterprise Linux AS 3.0
> Java: 1.5
>
> Can somebody help me regarding the same.
>
> Regards,
> Kiran Tadepalli
>
>
>
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com
>   

-- 
Mike Sabroff
Web Services
Developer
mike.sabroff@cygnusb2b.com
920-568-8379


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