Lately I was struggling with the JMX configuration of the glassfish application server (version 3.2.1) longer than initially expected. Maybe I should have read the glassfish documentation first but I was kind of lazy and started with trial and error. So if someone else wants to do the same thing here are the problems I faced and the steps to solve them.

In my case I wanted to read out the number of active HTTP sessions of a remote glassfish server using JMX. I started with JConsole to check which concrete JMX beans and attributes are offered by glassfish. I looked up the JMX connection port in the glassfish admin (default port is 8686) and tried to connect to the server:

After a little while I found out that you have to tell glassfish with certain JVM parameters that it should accept remote JMX connections (to make things easy no authentication was activated):

After a restart of the application server the connection with JConsole was successful. I was searching through the beans in JConsole but couldn’t find anything like number of sessions. I figured out that you have to activate the web-container monitoring (level=HIGH) in the glassfish admin to get this data:

jmx2_new

Activate web container monitoring in glassfish

 

After this is activated (no restart is required) you can see the session data of your instance in the glassfish admin:

jmx4_new

Monitor session data in glassfish

 

I thought the same is true now for reading the data with JConsole. Wrong! Still no session data available!?

I found out that glassfish offers this data through a special JMX interface called AppServer Management Extensions (AMX). However there was no amx node shown in JConsole only amx-support. Here you find a nice little button called bootAMX and when you click it the amx node (magically) appears:

jmx3_new

Call bootAMX explicitly using JConsole

 

This triggers the registration of all AMX MBeans by executing the JMX operation bootAMX on the MBean amx-support:type=boot-amx. However you have to repeat this after each restart of the server to renew the registration. According to the glassfish monitoring reference wiki other possibilities to register these beans are:

  • MEJB connection
  • JMXConnector client connection
  • explicit call to bootAMX()
  • AmxPref.getAutoLoad() is true

(I just found this page but did not try any of these options expect explicitly calling bootAMX using JConsole. Maybe some of you have experience how to activate AMX by default for every startup … let me know)

The session data can finally be found under amx/session-mon:

jmx5_new

Monitor glassfish session data in JConsole

 

I hope that post could help other glassfish users. Comments are welcome!

– Heiko

Leave a Comment

2 comments

  1. U

    Very nice article. Having similar lazy attitude like you mentioned it was great information and I really am thankful.
    Regards,
    Umair

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close