1 Reply Latest reply on May 4, 2004 1:43 PM by michaelklem

    How to Programmatically shut down JBoss

    ccaustin Newbie

      I'm hoping someone can tell me how to do this. I see that through the web JMX web console one can shut JBoss down. I would like to do this because when my application starts up I can tell if the database connection options are correct or not. If they are not, I want to have JBoss shutdown so the administrator can actually read my error message instead of seeing thousands of lines of JBoss error messages. Any suggestions or code examples would be much appreciated. Thanks.

        • 1. Re: How to Programmatically shut down JBoss
          michaelklem Newbie

          What I did was this:

          List serverList = MBeanServerFactory.findMBeanServer( null );
          MBeanServer server = (MBeanServer)serverList.iterator().next()

          get app server version
          if version 2.4.4
          server.invoke( "DefaultDomain:type=Shutdown", "shutdown" );
          else if version 3.0.x
          server.invoke( "jboss.system:type=Server", "shutdown" );

          To get the app server version:
          if ( jmxMgr.isRegistered( "jboss.system:type=Server" ) )
          String data = (String)jmxMgr.getAttribute( "jboss.system:type=Server", "Version" );

          This is simplified but hopefully will help you out