Announcement Announcement Module
Collapse
No announcement yet.
how to get the cluster,server and application names for TC server using JMX Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to get the cluster,server and application names for TC server using JMX

    I have installed Tc server with three instances (say myinstance1,myinstance2 and myinstance3 ) and deployed two web applications in each instance(say myinstance1-app1 and myinstance1-app2 ..)

    I need the jmx code to find out the instancenames and deployed application names in each instance.

    Thanks in advance.

  • #2
    You can get information about the names (and many other things) of the deployed applications. I'd recommend looking at a running instance with JConsole to get a feel for the MBeans and the operations that are available. For deployed applications take a look under Catalina/WebModule.

    The name of an instance is not available via JMX. However, as each instance must use a unique port for its JMX connection, you will already know which instance you're connecting to based on the port which you've used to connect.

    Comment


    • #3
      Thanks Wilkinson.

      From the Jconsole i am able to see methods under Catalina-->Serverability from this I am trying to invoke the operation(listApplications)but it is giving the method not found exception.

      MBeanServerConnection mbsc = jmxconn.getMBeanServerConnection();
      ObjectName obj = null;
      Vector paramsdata= new Vector();
      paramsdata.add(new String("Catalina"));
      paramsdata.add(new String("localhost"));
      Object[] params = {productData};
      obj = new ObjectName("tcServer:type=Serviceability,name=Depl oyer");
      String[] signs = {productData.getClass().getName()};
      Object o = mbsc.invoke(obj2, "listApplications", params, signs);

      is anything i missed out for invoking the Mbean operation


      I have one more doubt

      like in weblogic we have one adminserver and list of managed servers contains some applications. we are getting the list of targets, managed servers, applications from the Mbeans. Is this things can we get using tomcat.

      code related to weblogic:

      //get the domain runtime mbean server connectionusing the below jndi
      ("/jndi/weblogic.management.mbeanservers.domainruntime");

      //get the cluster and server
      ObjectName[] targets = (ObjectName[])(ObjectName[])connection.getAttribute(appObjName, "Targets");
      String type = null;
      for (int j = 0; j < targets.length; j++)
      {
      type = (String)connection.getAttribute(targets[j], "Type");

      if (type.equals("Cluster"))
      {
      ObjectName[] servers = (ObjectName[])(ObjectName[])connection.getAttribute(targets[j], "Servers");

      //get the application names
      connection = factory.getDomainRuntimeMBeanServer();
      ObjectName domainconfig = (ObjectName)connection.getAttribute(service, "DomainConfiguration");
      ObjectName[] deploymentNames = (ObjectName[])(ObjectName[])connection.getAttribute(domainconfig, "AppDeployments");
      for (int i = 0; i < deploymentNames.length; i++) {
      name = (String)connection.getAttribute(deploymentNames[i], "Name");
      label = new LabelValueBean(name, deploymentNames[i].toString());
      appNames.add(label);
      ObjectName[] targets = (ObjectName[])(ObjectName[])connection.getAttribute(deploymentNames[i], "Targets");
      for (int j = 0; j < targets.length; j++) {
      String type = (String)connection.getAttribute(targets[j], "Type");
      name = (String)connection.getAttribute(targets[j], "Name");
      }
      }

      Is there any other way to get the instance names and whole applicatio names from the hyperic level.

      Comment


      • #4
        Originally posted by aravind.sure View Post
        Thanks Wilkinson.

        From the Jconsole i am able to see methods under Catalina-->Serverability from this I am trying to invoke the operation(listApplications)but it is giving the method not found exception.

        MBeanServerConnection mbsc = jmxconn.getMBeanServerConnection();
        ObjectName obj = null;
        Vector paramsdata= new Vector();
        paramsdata.add(new String("Catalina"));
        paramsdata.add(new String("localhost"));
        Object[] params = {productData};
        obj = new ObjectName("tcServer:type=Serviceability,name=Depl oyer");
        String[] signs = {productData.getClass().getName()};
        Object o = mbsc.invoke(obj2, "listApplications", params, signs);

        is anything i missed out for invoking the Mbean operation
        You're not invoking the MBean operation correctly. The listApplications method has two arguments; the service name and the host name, both of which are Strings. To invoke this operation you'll need code something like the following:

        Code:
        mbsc.invoke(obj2, "listApplications", new String[] {"Catalina", "localhost"}, new String[] {String.class.getName(), String.class.getName()});

        Comment

        Working...
        X