Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Manage Apache Geronimo with JMX

Use JMX to configure, manage, and monitor Geronimo

J. Jeffrey Hanson (jeff@jeffhanson.com), Chief Architect, eReinsure.com, Inc.
Jeff Hanson
Jeff Hanson has more than 20 years of experience in the software industry, including work as senior engineer for the Microsoft® Windows® port of the OpenDoc project and lead architect for the Route 66 framework at Novell. Jeff is currently the chief architect for eReinsure.com, Inc. and builds Web service frameworks and platforms for J2EE-based reinsurance systems. Jeff is the author of numerous articles and books, including .NET versus J2EE Web Services: A Comparison of Approaches, Pro JMX: Java Management Extensions, and Web Services Business Strategies and Architectures

Summary:  The Java™ community has embraced the Java Management Extension (JMX) specification and framework as the standard for systems, applications, and resource management. The Apache Geronimo platform has been designed with manageability as a top priority, and JMX is one of the primary contributing technologies. Discover how to manage the Geronimo platform using JMX.

Date:  01 Aug 2006
Level:  Intermediate
Also available in:   Korean  Japanese

Activity:  8913 views
Comments:  

Apache Geronimo, which is built on a general-purpose Inversion of Control (IoC) kernel that supports the JMX framework, oversees a collection of managed components called Geronimo Beans (GBeans). Geronimo was created with JMX as the underlying kernel infrastructure, so it shares several similarities with JMX Managed Beans (MBeans). This structure has changed slightly over time, because using JMX as the framework for locating objects, interobject communication, method interception, and so on was seen as a stretch for JMX. However, the legacy of JMX is still evident in the Geronimo architecture, especially in the GBean framework.

JMX has become the de facto standard for managing resources within the Java platform, Java 2 Platform, Enterprise Edition (J2EE), and Java Enterprise Edition (Java EE). JMX defines a standard for dynamically instrumenting Java classes, interfaces, and runtime objects with attributes and operations that you can use for management purposes. JMX can instrument and manage any resource -- such as an application, device, or service -- that you can abstract using the Java programming language. Each managed resource is referred to as an MBean. JMX defines four types of MBeans:

  • Standard MBeans: Use Java interfaces to define their management attributes and operations.
  • Dynamic MBeans: Use runtime discovery to define their management attributes and operations.
  • Model MBeans: Act as proxies for objects that expose manageable operations and attributes.
  • Open MBeans: Use a predefined metadata vocabulary to expose the manageable attributes and operations of classes and objects.

The primary interface to interacting with MBeans is the javax.management.MBeanServer. The MBeanServer acts as a central repository of MBeans and facilitates communication with MBeans from clients. MBeans are uniquely identified by an ObjectName instance, which consists of:

  • A domain: An arbitrary name for a given domain. Conventions recommend using reverse Domain Name System (DNS) naming for domains in the same manner as Java package naming.
  • A key property list: An arbitrary, unordered set of keys and associated values.

You construct a typical ObjectName as follows:

String domain = "com.jeffhanson.test";
String keyPropertyList = "Name=TestBean,Type=GenericService";
ObjectName objName = new ObjectName(domain + ":" + keyPropertyList);



You can use ObjectName instances as parameters to many of the MBeanServer methods to retrieve attributes and invoke operations on an MBean. For example, you can invoke an operation on an MBean by obtaining a reference to the MBean server on which the invoke method is to be called. When you've obtained the reference to the MBean server, the ObjectName representing the target object of the invoke method is passed to the invoke method along with the operation name as the second parameter, followed by the remaining information that the MBean server requires to find and invoke the correct MBean. Geronimo still uses ObjectName instances to refer to GBeans in most of the method calls in which GBeans are involved.

JMX and its relationship with Geronimo's GBean framework

Virtually every significant object in Geronimo is a GBean. Geronimo's kernel, along with all other significant objects instantiated within the Geronimo platform, are instrumented as GBeans and exposed as JMX MBeans so that JMX-enabled tools can manage them. In this way, you can manage and monitor a running instance of Geronimo using standard portals, dashboards, and consoles.

GBeans in Geronimo expose attributes, operations, and notifications through the GBeanInfo class and propagate this information to the JMX MBeanInfo class. Figure 1 illustrates a high-level view of the relationships of Geronimo and JMX.


Figure 1. Geronimo and JMX relationships
Geronimo and JMX relationships

Table 1 shows the similarities between Geronimo GBeans and JMX MBeans.


Table 1. Similarities between MBeans and GBeans
PurposeMBeans useGBeans use
Hold data structures for operations, attributes, notifications, and constructors of a managed resourceAn MBeanInfo structureA GBeanInfo structure
Encapsulate information about constructors for managed resourcesA ConstructorInfo structureA GConstructorInfo structure
Encapsulate information about operations for managed resourcesAn MBeanOperationInfo structureA GOperationInfo structure
Encapsulate information about attributes for managed resourcesAn MBeanAttributeInfo structureA GAttributeInfo structure
Encapsulate information about notifications and events for managed resourcesAn MBeanNotificationInfo structureA GNotificationInfo structure

JMX also provides an application program interface (API) through which you can discover and view MBean information remotely. Geronimo provides support for this API, thereby allowing Geronimo to expose its set of GBeans as MBeans to remote clients.


Geronimo and JMX remoting

Geronimo supports the JMX Remote API (JSR 160) with which you can manage and monitor an MBean server remotely. JSR 160 specifies that JMX-enabled applications and services provide connectors that allow JMX clients to connect over supported protocols, such as HTTP and Remote Method Invocation (RMI). JSR 160 defines a mandatory RMI-based connector for all JMX Remoting implementations.

The jmx-remoting module, located in the org.apache.geronimo.jmxremoting package, provides remote access to a Geronimo server using JSR 160 JMX Remoting (see Resources for a link). You must have two Geronimo services up and running to enable Geronimo's RMI connector:

  • org.apache.geronimo.system.RMIRegistryService: Starts an RMI registry on a specified port
  • org.apache.geronimo.jmxremoting.JMXConnector: Creates an RMI connector server and exports it to the RMI registry specified in the connector server URL.

With the two services running, you can connect the code in Listing 1 to Geronimo's MBean server and perform operations on Geronimo's MBeans.


Listing 1. Connecting to Geronimo remotely
Map environment = new HashMap();
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());

The RMI connector in the previous example depends on a JMXServiceURL to point to the remote MBean server. The JMXServiceURL indicates where to find the connector's stub using an address built around a protocol (rmi in this case), a host (localhost in this case), a port (implied in this case), and a URL path (JMXConnector in this case). With a valid connection to the running Geronimo instance, you can use the code in Listing 2 to view information about all MBeans associated with the Geronimo kernel.


Listing 2. View MBean information for Geronimo's kernel
ObjectName kernelObjName =
   JMXUtil.getObjectName(":role=Kernel");

MBeanInfo mBeanInfo = mbServerConn.getMBeanInfo(kernelObjName);
if (mBeanInfo != null)
{
   System.out.println("\nDumping Kernel MBeanInfo...");
   dumpMBeanInfo(mBeanInfo);
}

Each MBean exposes a set of information about itself in the form of an instance of the MBeanInfo class. This information is encapsulated within attributes, operations, and notifications. Listing 3 demonstrates how you can view this information.


Listing 3. MBeanInfo instances bearing data for MBeans within Geronimo's kernel
private static void dumpMBeanInfo(MBeanInfo info)
{
   MBeanAttributeInfo[] aInfos = info.getAttributes();
   System.out.println("   Attribute Infos:");
   if (aInfos != null)
   {
      for (int i = 0; i < aInfos.length; i++)
      {
         System.out.println("      "
                            + aInfos[i].getType()
                            + " " + aInfos[i].getName());
      }
   }

   MBeanOperationInfo[] oInfos = info.getOperations();
   System.out.println("   Operation Infos:");
   if (oInfos != null)
   {
      for (int i = 0; i < oInfos.length; i++)
      {
         String signature = getSignature(oInfos[i]);
         System.out.println("      "
                            + oInfos[i].getReturnType()
                            + " " + oInfos[i].getName()
                            + signature);
      }
   }
}

private static String getSignature(MBeanOperationInfo oInfo)
{
   String signature = "(";
   MBeanParameterInfo[] paramInfos = oInfo.getSignature();
   if (paramInfos != null)
   {
      for (int j = 0; j < paramInfos.length; j++)
      {
         if (j > 0)
         {
            signature += ", ";
         }
         signature += paramInfos[j].getType();
      }
   }
   signature += ")";
    return signature;
}

Geronimo with JMX provides sufficient information to enable a comprehensive and powerful debugging environment. Geronimo exploits this environment with a browser-based debugging console that you can use for any Geronimo running instance.


Geronimo's JMX Debug Console

The Geronimo JMX Debug Console is a debugging tool that uses JMX to monitor the state of a running Geronimo server and to debug deployed applications. Add org/apache/geronimo/DebugConsole to the list of configurations on the Geronimo startup command line. Geronimo deploys the JMX Debug Console to the /debug-tool context of a running Geronimo instance -- that is, http://servername:8080/debug-tool/, where servername is the name of the computer on which the debug tool resides. The debug tool displays a list of MBeans that you can click to see additional information, which appears in a table on the right side of the page. Figure 2 shows an example of additional information for the Geronimo/jmxdebug-jetty/1.0/car MBean.


Figure 2. Additional information for an MBean within the Geronimo JMX Debug Console
geronimo/jmxdebug-jetty/1.0/car MBean

Geronimo and JMX consoles

Geronimo is closely integrated with JMX, so you can view and manage Geronimo's runtime information with any JMX-enabled console application or utility. This standardized interaction is one of the most useful benefits of JMX. The following section discusses how you can manage and monitor Geronimo using the MC4J JMX console.

Managing Geronimo's configuration and runtime information with the MC4J JMX console

MC4J is a Java open source project for creating management software based on JMX. It connects, manages, and monitors JMX-enabled applications, servers, and services using the standard remoting and instrumentation capabilities that the JMX specification provides.

You can download and execute the appropriate MC4J installation for your environment from the MC4J Web site (see Resources for the link). After you install the MC4J console, you can run it to manage and monitor a running instance of Geronimo or any JMX-enabled application. MC4J provides four primary panes to display properties, graphs, and other information of a JMX-enabled application, as shown in Figure 3.


Figure 3. MC4J's panes
MC4J's panes

MC4J can connect with a running instance of Geronimo through Geronimo's RMI server.

  1. Select Create Server Connection from the Management menu, and then choose Geronimo from the Server connection type list.
  2. Type systemfor the Principle value and manager for the Credentials value.
  3. Name this connection, and then click Next.
  4. Click Finish; MC4J loads the MBeans that Geronimo exposed.

Expand the Geronimo connection node in the Managed Objects Explorer pane to browse the attributes, operations, and notifications of Geronimo's MBeans. Figure 4 shows a typical view of MC4J's Managed Objects Explorer pane.


Figure 4. The MC4J Managed Objects Explorer pane
The MC4J Managed Objects Explorer pane

Right-click one of the MBeans, and then select Available dashboards. From the menu that appears, select Basic MBean View. Figure 5 shows how the Geronimo/jmxdebug-jetty/1.0/car MBean looks when you view it with the Basic MBean View dashboard.


Figure 5. The Basic MBean View dashboard
The Basic MBean View dashboard

You can perform real-time operations on Geronimo's MBeans using the Basic MBean View of the MC4J console. At this point, take some time to examine the vast number of values that you can configure and monitor in MC4J.


Linking Geronimo and JMX with MBeanServerKernelBridge and MBeanGBeanBridge

Geronimo offers a couple of classes that bridge the gap between the Geronimo GBean framework and the JMX MBean framework. The MBeanServerKernelBridge class registers each GBean that is loaded in Geronimo as an MBean in the associated MBeanServer instance. This behavior makes the process of exposing MBeans with Geronimo simply a matter of encapsulating them in a GBean and registering the GBean with the Geronimo kernel.

When an MBeanServerKernelBridge instance is started during kernel startup, it retrieves the list of all GBeans registered with the kernel and converts them to MBeans. These MBeans, in the form of MBeanGBeanBridge instances, are dynamic MBeans that maintain references to the Geronimo kernel and the information stored in the GBeanInfo references of each GBean.

Because the MBeanServerKernelBridge instance is registered as a GBean with the Geronimo kernel, it is registered automatically as a LifecycleAdapter implementation that receives loaded and unloaded events whenever you register new GBeans with the kernel. When a loaded or unloaded event occurs, the MBeanServerKernelBridge registers and unregisters each associated GBean as an MBean with the MBeanServer, thereby ensuring that JMX-aware clients are offered an accurate view of the current state of Geronimo and the Geronimo kernel.


Conclusion

Geronimo's creators designed the platform with manageability as a primary goal, and JMX is one of the essential technologies that Geronimo uses to realize this goal. Geronimo's close relationship with JMX enables fine-grained instrumentation capabilities for administering Geronimo's configuration and runtime properties.

Geronimo's general-purpose kernel supports the JMX framework to manage a repository of managed components called GBeans. Geronimo provides helper classes that bridge the gap between the Geronimo GBean framework and the JMX MBean framework, which makes the process of exposing MBeans with Geronimo simply a matter of registering them with a helper class that in turn registers the MBeans as GBeans with the Geronimo kernel.



Download

DescriptionNameSizeDownload method
Geronimo and JMX snippetsGeronimoJMX.zip38KB HTTP

Information about download methods


Resources

Learn

Get products and technologies

Discuss

About the author

Jeff Hanson

Jeff Hanson has more than 20 years of experience in the software industry, including work as senior engineer for the Microsoft® Windows® port of the OpenDoc project and lead architect for the Route 66 framework at Novell. Jeff is currently the chief architect for eReinsure.com, Inc. and builds Web service frameworks and platforms for J2EE-based reinsurance systems. Jeff is the author of numerous articles and books, including .NET versus J2EE Web Services: A Comparison of Approaches, Pro JMX: Java Management Extensions, and Web Services Business Strategies and Architectures

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source, Java technology, WebSphere
ArticleID=150155
ArticleTitle=Manage Apache Geronimo with JMX
publish-date=08012006
author1-email=jeff@jeffhanson.com
author1-email-cc=ruterbo@us.ibm.com