geronimo-dev mailing list archives

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

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"
javax.management.AttributeNotFoundException:  Cannot find attribute
contextPath for
StandardEngine[Geronimo].StandardHost[0.0.0.0].StandardContext[/console]
	at org.apache.tomcat.util.modeler.ManagedBean.getGetter(ManagedBean.java:490)
	at org.apache.tomcat.util.modeler.BaseModelMBean.getAttribute(BaseModelMBean.java:180)

The MEJB client code looks as follows:

        Properties props = new Properties();
        props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
        props.put("java.naming.provider.url", "127.0.0.1:4201");

        Context initialCtx = new InitialContext(props);
        Object mejbObj =
initialCtx.lookup("MEJBGBean/MEJB/javax.management.j2ee.Management");
        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>)
managed_object_set.iterator();
            while (it.hasNext()) {
                System.out.println(it.next());
                ObjectName webModule = it.next();
                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
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost/JMXConnector");
        JMXConnector jmxConnector =
JMXConnectorFactory.connect(address, environment);
        MBeanServerConnection mbServerConn =
jmxConnector.getMBeanServerConnection();
        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) {
            System.out.println(webModule);
            System.out.println(mbServerConn.getAttribute(webModule,
"contextPath"));
        }

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

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Mime
View raw message