2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Jakarta > HiveMind
Jakarta
 
Font size:      

JMX Quickstart

This chapter is for the impatient ones, that want to get up anything to play with quickly. If you have any problems with the setup you should follow these detailled setup instructions.

The quickstart assumes that you have a working HiveMind application that is running long enough to make management possible. For example this could be a web application or a gui application that keeps a window open.

Following the quickstart instructions you will be able to manage the log4j loggers of your application. This allows you to change log levels at runtime.

J2SE 1.3 or 1.4 and MX4J

These instructions work for a Tomcat 5.0.x web application for example. The management interface is rendered as HTML via the MX4J library.

Get MX4J in version 2.x. Put mx4j.jar, mx4j-tools.jar and log4j.jar in the classpath of your application. You can find the libraries in the ext-package/lib after an ant build of HiveMind too.

Add these lines to your application's HiveMind descriptor:

<contribution configuration-id="hivemind.EagerLoad">
  <load service-id="hivemind.management.MBeanRegistry"/>
</contribution>

<contribution configuration-id="hivemind.management.MBeans">
  <mbean service-id="hivemind.management.connector.HttpAdaptorMBean" 
         start-method="start" />
  <mbean service-id="hivemind.management.log4j.LogManagementMBean" />
</contribution>

<contribution 
   configuration-id="hivemind.management.log4j.ManagedLog4jLoggers">
  <logger name="*" />
</contribution>
       

Start your application and enter http://localhost:9000 in your browser. You will see a list of all manageable MBeans:

Screenshot of MX4J server view

Select on of the MBeans of "type=logger". Enter a priority like DEBUG on the next page to change the log level.

J2SE 1.5

J2SE 1.5 already includes JMX support and brings along a management console (jconsole). Get MX4J in version 2.x. Put mx4j.jar and log4j.jar in the classpath of your application. You can find the libraries in the ext-package/lib after an ant build of HiveMind too.

Add these lines to your application's HiveMind descriptor:

<contribution configuration-id="hivemind.EagerLoad">
  <load service-id="hivemind.management.MBeanRegistry"/>
</contribution>

<contribution configuration-id="hivemind.management.MBeans">
  <mbean service-id="hivemind.management.log4j.LogManagementMBean" />
</contribution>

<contribution 
   configuration-id="hivemind.management.log4j.ManagedLog4jLoggers">
  <logger name="*" />
</contribution>       
      

Start the application with -Dcom.sun.management.jmxremote

java -Dcom.sun.management.jmxremote ...
      

Start jconsole from JAVA_HOME/bin and connect to the running application that should be visible on the local tab:

JConsole local connect dialog

Now switch to the "MBean" tab and look in the "logger" subfolders for the logger MBeans. Select one:

JConsole logger MBean

Next steps

For more quick results try to add a performance interceptor for one of your services or just make a service manageable.