The Sample JMX Application
The sample Web application, called jmxapp
, is based on the JMXProxyServlet application provided with the Tomcat 5 installation. It uses an MBean descriptor file located at jmxapp/WEB-INF/classes directory/mbeans-descriptor.xml
. A Model MBean is instantiated within the JMX MBean Server for each manageable component listed in Table 2
I wrote custom Java classes to make the cluster elements JMX components. The cluster itself is not shown as part of the accessible JMX components accessible when you launch the Tomcat server. These custom classes provide useful statistics for a cluster monitoring and management framework. For example, session statistics such as default session timeout and number of currently active sessions are exposed as MBean attributes using the custom session manager class. You instantiate and register these MBeans when Tomcat server is started (Make sure you copy these class files to the %TOMCAT_HOME%/server/classes
directory because Tomcat requires these classes at startup time).
MBean Naming Syntax:
To provide unique names, JMX specifies a two part naming convention for MBeans. The parts are:
- JMX Domain: The domain name is a case-sensitive string that defines a top level within the JMX namespace. For example, the domain in Tomcat server is called "Catalina". Therefore, all the manageability components have MBeans names with a "Catalina" prefix.
- Key-Value Pairs: The second part of an MBean name is a set of one or more name-value pairs. These key properties create unique object names within a specific JMX domain and they provide information about the MBean. This set doesn't have to be ordered; in other words, the order of the key-value pairs is not significant, but the name must begin with the domain. Using key-value pairs, you can supply information such as names, host name, port, locations, application paths, and so forth as shown below
In the preceding line of code, Name
is the string that you provide when you created the managed resource that the MBean represents and Type
is the interface class of which the MBean is an instance.
Here's a more expansive example. The following three lines represent the MBeans names for the Service, Host, and Replication Valve components in Tomcat server.
Table 2 shows the list of MBeans monitored using the JMX Web application and their object names.
Table 2. Cluster MBean Names
Table 3 shows the list of attributes for the MBeans monitored by the sample Web application.
Table 3. Cluster MBeans and their attributes.
||Load Balancing Rule Name (Round Robin or Random)
Total number of instances
TCP Listen Address
TCP Listen Port
||Number of sessions
Manager Class Name
Number of ActiveSessions
Maximum Inactive Interval
Session Id, Creation Time, Last Accessed Time for each session
Request Filter details