geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacek Laskowski" <>
Subject Remote connection with JMX Remote, MEJB and DeploymentManager
Date Mon, 02 Jul 2007 23:07:13 GMT

I've been experimenting with remote access to Geronimo resources. I
can't understand why there are so many different ways to get the same
information - JMX Remote and MEJB seem to be pretty similar and
there's also DeploymentManager that lets retrieve information about
resources too. Should JMX Remote be preffered over MEJB? Which one is
the recommended solution to retrieve information about Geronimo
resources (webapps, ejbs, appclients, etc.).

Another issue I'm struggling with is to get at the information that
are displayed in the Geronimo Console. In JMX Viewer, there's
contextPath attribute for WebModule. Whenever a query for the
attribute is issued from a JMX Remote or MEJB client the following
exception is thrown:

Exception in thread "main"  Cannot find attribute
contextPath for
	at org.apache.tomcat.util.modeler.ManagedBean.getGetter(
	at org.apache.tomcat.util.modeler.BaseModelMBean.getAttribute(

The MEJB client code looks as follows:

        Properties props = new Properties();
        props.put("java.naming.provider.url", "");

        Context initialCtx = new InitialContext(props);
        Object mejbObj =
        ManagementHome mejbHome = (ManagementHome) mejbObj;
        Management mejb = mejbHome.create();

            ObjectName searchpattern = new ObjectName("*:j2eeType=WebModule,*");
            Set<ObjectName> managed_object_set = (Set<ObjectName>)
mejb.queryNames(searchpattern, null);
            System.out.println("found " + managed_object_set.size() +
" matching objects.");
            Iterator<ObjectName> it = (Iterator<ObjectName>)
            while (it.hasNext()) {
                ObjectName webModule =;
                mejb.getAttribute(webModule, "contextPath");

whereas the JMX Remote client is as follows:

        Map<String, String[]> environment = new HashMap<String, String[]>();
        String[] credentials = new String[] { "system", "manager" };
        environment.put(JMXConnector.CREDENTIALS, credentials);

        JMXServiceURL address = new
        JMXConnector jmxConnector =
JMXConnectorFactory.connect(address, environment);
        MBeanServerConnection mbServerConn =
        System.out.println("DefaultDomain: " + mbServerConn.getDefaultDomain());

        ObjectName searchpattern = new ObjectName("*:j2eeType=WebModule,*");
        Set<ObjectName> webModules = (Set<ObjectName>)
mbServerConn.queryNames(searchpattern, null);
        for (ObjectName webModule : webModules) {

Why is the exception thrown? How does the console get the value of the
contextPath attribute?


Jacek Laskowski

View raw message