Using JMX and J2SE 5.0 to Securely Manage Web Applications
Added 31 Jul 2008
JMX (Java Management Extensions) supplies tools for managing local and remote applications, system objects, devices, and more. This article will explain how to remotely manage a web application using JMX (JSR 160). It will explain the code needed inside of the application to make it available to JMX clients and will demonstrate how to connect to your JMX-enabled application using different clients such as MC4J and jManage. Securing the communication layer using the RMI protocol and JNDI is also covered in detail.
We will review a simple web application that monitors the number
of users that have logged in and exposes that statistic via a
secure JMX service. We will also run multiple instances of this
application and track statistics from all running instances. The
sample web application can be downloaded here. It requires you to have the J2SE 5.0 SDK
installed and your JAVA_HOME environment variable
pointing to the base installation directory. J2SE 5.0 implements
the JMX API, version 1.2, and the JMX Remote API, version 1.0. A
supporting servlet container is also required; I'm using
Apache Tomcat
5.5.12. I'm also using Apache
Ant to build the sample application.
Setting up the Sample Application
Download the sample application and
create a WAR file with ant war (for more
details, see the comments in build.xml). Copy jmxapp.war
to Tomcat's webapps directory. Assuming Tomcat is running on
your local machine on port 8080, the URL for the application will
be:
http://localhost:8080/jmxapp