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
Table 1 shows the similarities between Geronimo GBeans and JMX MBeans.
Table 1. Similarities between MBeans and GBeans
| Purpose | MBeans use | GBeans use |
|---|---|---|
| Hold data structures for operations, attributes, notifications, and constructors of a managed resource | An MBeanInfo structure | A GBeanInfo structure |
| Encapsulate information about constructors for managed resources | A ConstructorInfo structure | A GConstructorInfo structure |
| Encapsulate information about operations for managed resources | An MBeanOperationInfo structure | A GOperationInfo structure |
| Encapsulate information about attributes for managed resources | An MBeanAttributeInfo structure | A GAttributeInfo structure |
| Encapsulate information about notifications and events for managed resources | An MBeanNotificationInfo structure | A 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 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.
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 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 can connect with a running instance of Geronimo through Geronimo's RMI server.
- Select Create Server Connection from the Management menu, and then choose Geronimo from the Server connection type list.
- Type
systemfor the Principle value andmanagerfor the Credentials value. - Name this connection, and then click Next.
- 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
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
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.
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.
| Description | Name | Size | Download method |
|---|---|---|---|
| Geronimo and JMX snippets | GeronimoJMX.zip | 38KB | HTTP |
Information about download methods
Learn
- Get an excellent overview of JMX in "From black boxes to enterprises,
Part 1: Management, JMX 1.1 style" (developerWorks, September 2002).
- Get an introduction to GBeans in "Dependency
injection in Apache Geronimo, Part 2: The next generation" (developerWorks,
February 2006).
- Find JMX documentation and
downloads.
- Get the specification for JMX Remoting.
- Visit the MC4J Web site for a comprehensive management console
for JMX-enabled implementations.
- Get resources for Geronimo at the
The Apache.org Geronimo site.
- Check out the developerWorks Apache Geronimo project area for articles, tutorials, and other resources to help you get started developing with Geronimo today.
- Find helpful resources for beginners and experienced users at the Get started now with Apache Geronimo section of developerWorks.
- Check out the IBM Support for Apache Geronimo offering, which lets you develop Geronimo applications backed by world-class IBM support.
- Visit the developerWorks Open source zone for extensive how-to information, tools, and project updates to help you develop with open source technologies and use them with IBM's products.
- Browse all the Apache articles and free Apache tutorials available in the developerWorks Open source zone.
- Browse for books on these and other technical topics at the Safari bookstore.
-
Stay current with
developerWorks
technical events and webcasts.
Get products and technologies
- Download Apache Geronimo, Version 1.1.
- Innovate your next open source development project with IBM trial software, available for download or on DVD.
- Download your free copy of IBM WebSphere® Application Server Community Edition V1.0 -- a lightweight J2EE application server built on Apache Geronimo open source technology that is designed to help you accelerate your development and deployment efforts.
Discuss
- Participate in the discussion forum.
- Get involved in the developerWorks community by participating in developerWorks blogs.

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




