Results 1 to 4 of 4

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

Hybrid View

  1. #1

    Exclamation 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. #2
    Join Date
    Oct 2008
    Posts
    493

    Default

    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.
    Andy Wilkinson
    SpringSource

  3. #3

    Question

    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.

  4. #4
    Join Date
    Oct 2008
    Posts
    493

    Default

    Quote 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()});
    Andy Wilkinson
    SpringSource

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •