2 Replies Latest reply on Jul 3, 2004 11:04 PM by Elias Ross

    how to find jboss server status, if it is stopped

    maheedhar p Newbie

      Hi,

      Can any one suggest, how to find the jboss server status?

      My application has a requirement to start the jboss server only if it is not already started.

      I am able to find the status, if the server is already running, by accessing the respective MBean ("jboss.system:type=Server" MBean has a read only attribute "Started").

      Following is the code snippet I used.

      InitialContext ic;
      Properties jndiProperties;
      RMIAdaptor server;
      ObjectName name;
      MBeanInfo info;
      try {
       jndiProperties = new Properties();
       jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
       jndiProperties.put(Context.PROVIDER_URL, "localhost:1099");
       ic = new InitialContext(jndiProperties);
       server = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor");
       name = new ObjectName("jboss.system:type=Server");
       boolean serverStatus;
       serverStatus = ((Boolean)server.getAttribute(name, "Started")).booleanValue();
       System.out.println("serverStatus="+serverStatus);
      } catch(Exception ex)
      {
       ex.printSTackTrace();
      }
      


      By the way, Does Pinging 1099 port help in identifying the server status?

      TIA

      Maheedhar