JBoss Developer Studio 4.1

JMX Tools Reference Guide

Provides information relating to the JMX Tools module.

Edition 4.1.0

JBoss Tools Team

Legal Notice

Copyright © 2011 Red Hat.
This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack Logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.

Abstract

The JMX Tools Reference Guide explains how to use the JMX Tools module to setup multiple JMX connections and explore the JMX tree and execute operations.

Preface

This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. To get more information on these conventions please refer to the Document Conventions manual, which can be found on the Red Hat Documentation website under the JBoss Developer Studio section.

Chapter 1. Introduction

JBoss Tools' JMX project is a fork of eclipse-jmx, a project by Jeff Mesnil. It was forked with permission.

1.1. What is JMX?

The Java Management Extensions (JMX) technology is a standard part of the Java Platform, Standard Edition (Java SE platform). The JMX technology was added to the platform in the Java 2 Platform, Standard Edition (J2SE) 5.0 release.
The JMX technology provides a simple, standard way of managing resources such as applications, devices, and services. Because the JMX technology is dynamic, you can use it to monitor and manage resources as they are created, installed and implemented. You can also use the JMX technology to monitor and manage the Java Virtual Machine (Java VM).
The JMX specification defines the architecture, design patterns, APIs, and services in the Java programming language for management and monitoring of applications and networks.
Using the JMX technology, a given resource is instrumented by one or more Java objects known as Managed Beans, or MBeans. These MBeans are registered in a core-managed object server, known as an MBean server. The MBean server acts as a management agent and can run on most devices that have been enabled for the Java programming language.
The specifications define JMX agents that you use to manage any resources that have been correctly configured for management. A JMX agent consists of an MBean server, in which MBeans are registered, and a set of services for handling the MBeans. In this way, JMX agents directly control resources and make them available to remote management applications.
The way in which resources are instrumented is completely independent from the management infrastructure. Resources can therefore be rendered manageable regardless of how their management applications are implemented.
The JMX technology defines standard connectors (known as JMX connectors) that enable you to access JMX agents from remote management applications. JMX connectors using different protocols provide the same management interface. Consequently, a management application can manage resources transparently, regardless of the communication protocol used. JMX agents can also be used by systems or applications that are not compliant with the JMX specification, as long as those systems or applications support JMX agents.

1.2. What is JMX Tools?

JBoss JMX Tools allows you to setup multiple JMX connections, and provides a view for exploring the JMX tree and execute operations directly from within Eclipse.
This chapter covers the basics of working with JMX plugin, which is used to manage Java applications (with Managed Beans) through JMX and its RMI Connector.
JMX Tools

Figure 1.1. JMX Tools


1.3. Key Features of JMX Tools

The table below lists the main features of JBoss JMX Tools:

Table 1.1. Key Functionality for JBoss JMX Tools

Feature Benefit Chapter
MBean Explorer
MBean Explorer is a useful view with a text filter that displays domains, mbeans, attributes, and operations inside a connection.
mbean_explorer
MBean Editor
MBean Editor is a multi-page editor to manage MBeans.
mbean_editor

1.4. Requirements and Installation

1.4.1.  Requirements

Requirements to use JBoss JMX Tools are the following:
  • JBoss JMX Tools is developed on Eclipse 3.4.x milestones
  • JBoss JMX Tools requires that Eclipse is run on a JDK 1.5.0 or above (due to dependencies on JMX packages which were introduced in Java 1.5.0)

1.4.2. Installation

Here, we are going to explain how to install the JMX plugin into Eclipse.
JBoss JMX Tools is one module of the JBoss Tools project. JBoss JMX Tools has no dependency on any other part of JBoss Tools, and can be downloaded as a stand alone Eclipse plugin. Even though the JMX Tools have no dependencies on other plugins, such as AS Tools, JBoss JMX Tools do depend on the JMX Tooling and even extend it.
You can find the JBoss Tools plugins over at the download pages. The only package you will need to get is the JBoss JMX Tooling, however the AS Tools would give you a wider experience and more options when using JMX with JBoss Servers. You can find further download and installation instructions on the JBoss Wiki in the InstallingJBossTools section.

Chapter 2. JMX Tools Tasks

This chapter will provide answers to common questions asked by JMX plugin users.

2.1. Quick Start

To start using the JMX Tools it is necessary to open MBean Explorer. Select WindowShow ViewOther, select MBean Explorer and click the OK button.
The MBean Explorer lists all the domains, MBeans, attributes, and operations inside a connection. When you double-click an MBean in the MBean Explorer, it opens a multi-page editor to manage the MBean. The MBean Editor is composed of these pages:
  • Attributes page, to get/set the attributes of the MBean
  • Operations page, to invoke operations on the MBean
  • Notifications page, to receive notifications from the MBean
  • Info page, which displays general information about the MBean

2.2. Managing Application

As it has been said earlier in the guide, the JMX technology allows you to monitor and manage Java applications. In this section we will show you how to get connected to a sample Java application and run the sayHello() method remotely from inside of the MBean Explorer.
  1. Save the bundle of JMX API sample classes, jmx_examples.zip, to your working directory.
  2. Unzip the bundle of sample classes.
  3. Compile the example Java classes from within where you unpacked the files directory.
    javac com/example/*.java
  4. Start the Main application, specifying the properties that expose Main for remote management:
             
    java -Dcom.sun.management.jmxremote.port=9999 \
    -Dcom.sun.management.jmxremote.authenticate=false \
    -Dcom.sun.management.jmxremote.ssl=false \
    com.example.Main
    
    If everything was done correctly you will see the
    Waiting for incoming requests...
    message on the screen.
  5. Now launch the Eclipse IDE, in Eclipse open the MBean Explorer. Go to WindowShow ViewOther, select MBean Explorer, and then click the OK button)
  6. Click the New Connection icon in the MBean Explorer menu bar.
  7. In the Create JMX Connection dialog, click the Next button and then click the Advanced tab.
  8. In the JMX URL input field enter the following URL:
    service:jmx:rmi:///jndi/rmi://:9999/jmxrmi
    JMX Connection

    Figure 2.1. JMX Connection


  9. Click the Finish button to establish the connection with the application.
  10. Now expand the connection you have just created, open the com.example package, and click the sayHello() method.
    Once the sayHello() method is selected the MBean Editor is activated.
  11. In the MBean Editor go to the Operation Details section and click the sayHello() button.
    You will get the "Operation invoked successfully" message.
    Invoking Method via JMX

    Figure 2.2. Invoking Method via JMX


  12. The final step is to make sure the application worked as expected. Open the terminal where you launched the application in step 3. You should see output similar to the following:
    [matthew@localhost jmx_examples]$ java -Dcom.sun.management.jmxremote.port=9999 \
    > -Dcom.sun.management.jmxremote.authenticate=false \
    > -Dcom.sun.management.jmxremote.ssl=false \
    > com.example.Main
    Waiting for incoming requests...
    hello, world

2.3. Tomcat Managing

It is possible to manage Tomcat using JMX Tools.
Currently, JMX Tooling is able to connect to Tomcat without authentication or with password-based authentication.
Using SSL for authentication is not supported: you need to make sure that the System property com.sun.management.jmxremote.ssl is set to false.
More information to manage Tomcat can be found in the Tomcat management documentation.
Instructions to remotely manage Tomcat are available in Tomcat's monitoring documentation.

2.4. Eclipse Equinox Managing

You can manage Equinox through the Equinox monitoring framework.
In this section we will show you how to connect to an Equinox server via JBoss JMX tools. First you need to create a simple servlet and run it on a server. The process of building applications and running them on the server is beyond the scope of this documentation, however this tutorial can be used to give you a better idea of how to build server-based applications with Eclipse Equinox.
Once you have an application running on the server you can connect to it using JBoss JMX tools.
  1. Go to WindowOpen PerspectiveOther and select the JMX perspective.
  2. Switch to the MBean Explorer by selecting WindowShow ViewOther and selecting the MBean Explorer option.
  3. Click the New Connection icon in the MBean Explorer menu bar.
  4. Select the Advanced tab and set the JMX URL to service:jmx:rmi:///jndi/rmi://:8118/jmxserver.
    Using JMX Tools to Access Equinox Server

    Figure 2.3. Using JMX Tools to Access Equinox Server


You now have access to the MBeans exposed by Equinox.

2.5. Managing JBoss AS

Managing JBoss instances is not supported with the JMX Tools alone. You must also download and install the AS Tools portion of the JBoss Tools distribution. Even after installing the proper tooling, you cannot create a JBoss JMX connection yourself or through the Connection Wizard. The first step is to create a JBoss Server. The full instructions for this can be found in the AS Tools section, however, the short summary is:
  1. Open the Servers view.
  2. Bring up the views context menu and select NewServer.
  3. In the JBoss Enterprise Middleware or in JBoss Community section, select a server version.
  4. If a runtime has not yet been created, you will be prompted for the server's home directory, JDK, and configuration.
  5. Finish the wizard and note that you have a new entry in both the Servers view and the MBean Explorer.
  6. Start the server by right-clicking it and selecting the Start option.
  7. Note that once the server is started, the JMX connection can be expanded.
Now you can explore MBeans exposed by a JBoss instance.

2.6. Managing JBoss AS Remotely

The JBoss JMX Tools allow you to easily access and manage a JBoss AS server remotely. In order to connect to the instance of JBoss AS remotely you need to run the server or make sure the server is launched.
  1. Select WindowOpen PerspectiveOther and select the JMX perspective option.
  2. Switch to the MBean Explorer by selecting WindowShow ViewOther and selecting the MBean Explorer option.
  3. Click the New Connection icon in the MBean Explorer menu bar.
  4. Select the Advanced tab and set the JMX URL to:
    service:jmx:rmi://localhost/jndi/rmi://localhost:1090/jmxconnector
    Please note that in this example we are connected to the local host.

2.7. Extension Task

This section will outline how to contribute your own Server type with some default behavior.

2.7.1. Why we should do that?

You might be asking yourself why you would need to extend this framework if JMX is a standard. Perhaps you want a connection to be automatically created after some specific action, or perhaps you want your connection wizard to do more than simply set a host and port. JBoss, for example, requires setting some credentials on the client machine, but uses JBoss classes to do it. This requires that the connection has access to the JBoss JARs.

2.7.2. Core Extensions

To create your own JMX Connection type, you must use the org.jboss.tools.jmx.core.MBeanServerConnectionProvider extension point. This point takes one child, a connectionProvider with a class that implements org.jboss.tools.jmx.core.IConnectionProvider.
An IConnectionProvider is responsible for creation and deletion of IConnectionWrapper objects. It must also keep a list of listeners that it is expected to notify when a connection is added or removed from its list.
Each IConnectionWrapper is expected to be able to run arbitrary JMX runnables or getting a "Root" object representing all JMX nodes. There are some utility methods the IConnectionWrapper can make use of.

2.7.3. UI Extensions

There are two extension points currently approved for use in the UI
  • org.jboss.tools.jmx.ui.providerUI - provide an icon, id, displayable name, and wizardPage class for creation of new connections
  • org.jboss.tools.jmx.ui.attribute.controls - allows you to map class types to some Control to present them in the MBean Editor
    We hope this guide helped you to get started with the JBoss JMX Tools. For additional information you are welcome on the JBoss forum.

2.8. Connections Creation Task

The MBean Explorer supports several different types of connections. The tooling itself comes only with a default connection type, however other adopters can provide additional connection types that may require additional or non-spec behavior. Connections can be in either the connected state or the disconnected state. Some connection types (such as the default connection type) allow you to control the current state. Other connection types may not.
Similarly, some connection types may be able to be created, and others may not. The default connection type, for example, can be created and deleted at will. The AS Tools connection type, which represents a JBoss server, does not allow you this level of control. A JBoss JMX connection is created when a JBoss server is created in the server's view, and deleted when said server is deleted. The JMX connection for this server is in the connected state only when the server is started.

2.8.1. Establishing Connection

There are two ways to connect to an application with remote management enabled:
The first step is the same for both methods - to connect to a MBean Server, click the New Connection icon in the MBean Explorer menu bar.
The simple method is to specify the host, port (and optionally user name and password) and click the OK button.
On the Advanced tab you can set the sever name (it will be displayed in MBean Explorer), and a URL to the remote server. For example, to connect to JBoss AS you need to set the JMX URL to
service:jmx:rmi://localhost/jndi/rmi://localhost:1090/jmxconnector
If it is required you can enter user name and password for the server connection.

Note

Only JMX URL based on RMI are supported.

Chapter 3. References

3.1. MBean Explorer

The MBean Explorer displays the MBean features (both attributes and operations) in its hierarchy. Double-clicking on a feature will open an MBean Editor, displaying the page corresponding to the feature type and select the feature.
MBean Explorer Features

Figure 3.1. MBean Explorer Features


Since it is possible to have many MBean Editors opened at the same time, the MBean Explorer has the Link With Editor button to synchronize selections between the active MBean Editor and the MBean Explorer (and vice versa).
The MBean Explorer has also a filter that can be used to filter the available MBeans to show those that interest you.
For example, if you are only interested by MBeans related to memory, typing "memo" will show any node (domain, mbean, attribute, or operation) that matches that text, as well as that node's parents and children. So if an MBean matches, all attributes and operations from that bean will be displayed. If, however, an attribute or operation name (a leaf node) matches, only that node and its parents in the tree will be displayed.
Query Filter

Figure 3.2. Query Filter


The Collapse All button on the MBean Explorer toolbar is used to collapse all the MBeans and display only the domains. It is also possible to double click on a node to expand or collapse it.

3.2. MBean Editor

MBean Editor Pages

Figure 3.3. MBean Editor Pages


The MBean Editor is composed of several pages:
  • the Attributes page
  • the Operations page
  • the Notifications page
  • the Info page
The Attributes and Operations pages display a list for either the MBean attributes or operations, as well as details about the selection.
It is possible to toggle the layout between the list and the details either vertically (by default) or horizontally with the help of the special icons in the right top corner of the editor.
MBean Editor Horizontal Layout

Figure 3.4. MBean Editor Horizontal Layout


The Visual Page Editor, showing both the source and a visual preview simultaneously.

Figure 3.5. Visual Page Editor


3.2.1. Notifications Page

The Notifications page provides the ability to subscribe or unsubscribe to an MBean to receive its notifications by checking or unchecking the Subscribe button in the right top corner.
The list of notifications is refreshed every time a new notification is received:
MBean Editor Notifications Page

Figure 3.6. MBean Editor Notifications Page


Note

It is only possible to subscribe to an MBean that emits notifications (i.e. they must be a NotificationBroadcaster).

Chapter 4. Summary

This document has provided an overview of the functionality included with JXM Tools, as well as walking you through the steps on managing Tomcat, Eclipse Equinox or JBoss Instances and how to create new JMX connections. If you have questions or suggestions concerned both the documentation and tools behavior, you are welcome to JBoss Tools Users forum. Please, use Jira to report bugs and requests on documentation.

4.1. Other relevant resources on the topic

You can find the JBoss Developer Studio/JBoss Tools release documentation at http://docs.jboss.org/tools in the corresponding release directory.
The latest documentation builds are available at http://download.jboss.org/jbosstools/nightly-docs.
The JBoss JXM Wiki can be found at http://www.jboss.org/community/wiki/JBossMX
For more information about JMX technology please visit JMX Technology Home Page

Getting Help and Giving Feedback

A.1. Do You Need Help?

If you experience difficulty with a procedure described in this documentation, visit the Red Hat Customer Portal at http://access.redhat.com. Through the customer portal, you can:
  • search or browse through a knowledgebase of technical support articles about Red Hat products.
  • submit a support case to Red Hat Global Support Services (GSS).
  • access other product documentation.
Red Hat also hosts a large number of electronic mailing lists for discussion of Red Hat software and technology. You can find a list of publicly available mailing lists at https://www.redhat.com/mailman/listinfo. Click on the name of any mailing list to subscribe to that list or to access the list archives.

A.2. Give us Feedback

If you find a typographical error, or know how this guide can be improved, we would love to hear from you. Submit a report in Bugzilla against the product JBoss Developer Studio and the component JMX Tools Reference Guide. The following link will take you to a pre-filled bug report for this product: http://bugzilla.redhat.com/.
Fill out the following template in Bugzilla's Description field. Be as specific as possible when describing the issue; this will help ensure that we can fix it quickly.
Document URL:


Section Number and Name:


Describe the issue:


Suggestions for improvement:


Additional information:


Be sure to give us your name so that you can receive full credit for reporting the issue.

Revision History

Revision History
Revision 4.1.2-1.406Tue Jan 7 2014Rüdiger Landmann
Rebuild with Publican 4.0.0
Revision 4.1.2-1Thu Aug 29 2013Michelle Murray
TOOLSDOC-387: Rebuilt for Customer Portal, content unchanged
Revision 2-0Thu Jan 20 2011JBoss Tools Documentation Team
General updates
Revision 1-0Wed Jun 09 2010JBoss Tools Documentation Team
Two new sections added and general updates
Revision 0-0Fri Nov 20 2009Isaac Rooskov
Initial creation of book by publican