JMX Client Code to Start Stop Suspend and Resume Weblogic Server using ServerRuntimeMBean

ServerRuntimeMBean provides methods for retrieving runtime information about a server instance and for transitioning a server from one state to another. Have a look at ServerRuntimeMBean’s API here.

Let’s look at the code below to start. stop, suspend and resume the Weblogic Server using ServerRuntimeMBean. This code also provides way to get the server state at any point of time.

Thus, by using the code above, weblogic server can be started, stopped, paused and resumed remotely. Hope you liked the information presented here. Feel free to leave your footprints in the comments section below for any queries, feedback or suggestions.

  1. Hi Thanks for the code, have a couple of ques here.

    1 have a admin server in which 3 managed servers are configured say admin url (http://189.34.56.143 and Port is 8001
    Managed server configuration is
    server name: server1
    IP: http://172.45.67.432
    Port: 7777
    Could you pls tell what hast to be replaced from your code in the place of
    port,url,hostname

    Thanks,
    Pingo…

  2. javax.management.InstanceNotFoundException: com.bea:Name=Server-01,Type=ServerRuntime

    Caused by: javax.management.InstanceNotFoundException: com.bea:Name=Server-01,Type=ServerRuntime

  3. As mention by wahwah and sumit, the code can’t start the server. I have hard coded the service name and manage to shut it down. but using the same service name, i can’t bring it back up. it throws a javax.management.InstanceNotFoundException, which is the same as what wahwah has mention.

    any solution anyone?

  4. in order to restart server we need to connect to domain mbean and admin server. in above script if server goes down you are loosing reference of it that is why getting instance not found exception.

    • @Pradeep: you’re absolutely rite. Do we have any other option to start the admin & managed servers using java (not WLST). If so then plz share it…

      • For starting a server, you can try this:

        ObjectName service = new ObjectName(“com.bea:Name=,Type=ServerLifeCycleRuntime”);
        connection.invoke(service, “start”, new Object[] {}, new String[] {});

        You can also use the ServerLifeCycleRuntimeMBean for suspending and stopping a server, if you want. In the code in the blog post, you could use it as a drop-in replacement for the ServerRuntimeMBean.

  5. @Admin
    Wahaha is right i face same issue
    it resolved by chaange this line :
    String mserver = “weblogic.management.mbeanservers.runtime”;
    by
    String mserver = “weblogic.management.mbeanservers.domainruntime”;

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">