-
1. Re: Why System.exit in MBean can not halt the JVM??
peterj Sep 19, 2005 10:52 AM (in response to yielruse)Here is my guess.
JBoss is muti-threaded. The only thing that System.exti(-1) accomplished is that it killed the thread you were running on and set the program exit code. The other threads are still running. To successfully kill the whole application, you must terminate all of the threads. (Actually, the best way to get JBoss to terminate is to send it the terminate signal.) -
2. Re: Why System.exit in MBean can not halt the JVM??
yielruse Sep 22, 2005 12:41 AM (in response to yielruse)I don't think so.
Well, in the javadoc of System.exit(int ), it says that: the method will halt the entire JVM. When the entire JVM is halted, then all threads running in it will be certainly terminated. So your guess is not possible.
Any other advice please. -
3. Re: Why System.exit in MBean can not halt the JVM??
frito Sep 22, 2005 3:24 AM (in response to yielruse)If I should have to write an application server, I would install a SecurityManager with an overwritten checkExit method, so nobody can halt the system just by calling System.exit() within deployed code ;-)
Read this regarding threads (daemon threads) and the system exit.
http://java.sun.com/j2se/1.3/docs/api/java/lang/Thread.html -
4. Re: Why System.exit in MBean can not halt the JVM??
yielruse Sep 22, 2005 4:14 AM (in response to yielruse)THX.
But my purpose is to stop JBoss via calling System.exit(), not to prevent others to halt the JVM. -
5. Re: Why System.exit in MBean can not halt the JVM??
frito Sep 22, 2005 6:36 AM (in response to yielruse)So why don't you call shutdown() on the MBean jboss.system.Server?
-
6. Re: Why System.exit in MBean can not halt the JVM??
yielruse Sep 22, 2005 8:11 AM (in response to yielruse)Because I must shutdown the JBoss when the my application server's initializaion is not complete.
So far I don't know any other way to stop JBoss except calling System.exit().
But now, I will take your advice to try to use shutdown() method in org.jboss.system.Server. -
7. Re: Why System.exit in MBean can not halt the JVM??
yielruse Sep 22, 2005 9:15 AM (in response to yielruse)yeah.........
Done.
Thanks to all people who have give me a hand.
When use shutdown() in MBean, the JBoss can't really shutdown.
When use exit(int) in MBean, the JBoss will shutdown after deploying all deployment,.
When use halt(int) in MBean, the JBoss immediately shutdown.
Thus, I use halt(int) to shutdown JBoss.
PS, all the three mehod list above is member method of org.jboss.system.server.ServerImplMBean, whose instance make out a JBoss.