Last time on the Tai-Dev Blog...
As I blogged previously, I was having problems running GlassFish (GF) on Windows Web Server 2008 which was ultimately connected with the GFJMX configuration. The solution I found (and my advice in the blog entry) was to simply disable the JMX interface by modifying the domain.xml config file.
However, as is typical with real world software deployment, a short time after I disabled JMX on a production GF instance and deployed a client's latest application we ran in performance issues which only showed up on a live deployment - of course we needed to utilise JMX to explore what was going on within GF and the JVM...
The (Updated) Solution
A fellow consultant, Piers Geyman, also working on the project ultimately discovered a work around which allowed us to enable JMX. The key part of the solution is to load the glassfish /domains/domain1/config/domain.xml file and change the default "address" attribute value from "0.0.0.0" to "127.0.0.1" (localhost), and also make sure that the enabled and port attribute values are set correctly (as highlighted below)
<jmx-connector accept-all="false" address="127.0.0.1" auth-realm-name="admin-realm" enabled="true" name="system" port="8686" protocol="rmi_jrmp" security-enabled="false">
<ssl cert-nickname="s1as" client-auth-enabled="false" ssl2-enabled="false" ssl3-enabled="true" tls-enabled="true" tls-rollback-enabled="true"/>
Simply restart your GF domain and not only should GF now re-start, but you will also be able to utilise JMX!
Many thanks to Piers for the help with this problem!
It should be noted that this will only allow access to JMX services via the localhost (i.e. you will have to login to you server via RDC in order to run monitoring tools etc). Piers mentioned that as JMX utilises RMI it is not simply a matter of opening port 8686 to the outside world in order to allow JMX to be utilised remotely as RMI can use random ports for each connection. Unless you fancy opening all potential ports (definitely not recommended) I would settle for local access to the JMX service...
Utilising JConsole to Monitor GlassFish Applications
Now that I had the JMX service running I was keen to fire up JConsole to find out more information about our apps!
I did have an initial problem connecting successfully to the JMX service on GF, but adding the following value to the GF JVM Options (either via the GF Admin Console or manual edit of the domain.xml file) and restarting the server allowed everything to run correctly...
You can start JConsole from the CLI (providing you have the path to the JDK bin directory set correctly) by simply typing:
In the window that is displayed enter your GlassFish JMXServiceURL in the "Remote Process" box e.g.
Don't forget to check your port number is set correctly in the above URL. Finally enter the GF Administration username and password in the boxes below. Click "Connect" and wait a few minutes while JConsole connects to GF...
You should now be set to begin monitoring your apps! Enjoy
Daniel Bryant (Director) | Tai-Dev Ltd www.tai-dev.co.uk - IT Consultancy Services Specialising in JEE, Web 2.0 and RDBMS