Remote Glassfish V3.1 and the mystical JMX settings

Once you have any serious sized application running on Glassfish, you need to profile and tune your server settings. A good tool to look under the hood of a running Glassfish is to to connect jconsole (part of JDK) to its JVM. This works without problem for a local Glassfish but when it comes to a remote instance you cant connect to the default Glassfish setup.

Lets look at the default setup

Glassfish Admin Console

JMX Connector (default)

JMX Connector (default)

..
      <admin-service system-jmx-connector-name="system" type="das-and-server">
        <jmx-connector port="8686" address="0.0.0.0" security-enabled="false" auth-realm-name="admin-realm" name="system"></jmx-connector>
        <property name="adminConsoleContextRoot" value="/admin"></property>
        <property name="adminConsoleDownloadLocation" value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"></property>
        <property name="ipsRoot" value="${com.sun.aas.installRoot}/.."></property>
        <das-config></das-config>
      </admin-service>
..
 

By changing the above default parameters I was not able to connect to remote Glassfish.
Only after adding these JVM parameters:

-Djava.rmi.server.hostname=yourhostname 
-Dcom.sun.management.jmxremote.port=8686
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Basically we are controlling the underlying JVM not the Glassfish instance.

JVM Settings

Please beware, with these settings anyone can login. So you need to adjust the settings accordingly, btw if you change the Glassfish JMX connector settings, nothing will change (eg. enable security).

If you enable the

-Dcom.sun.management.jmxremote.authenticate=false

you will get this:

Waiting for domain1 to start .Error starting domain domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Error: Password file read access must be restricted: /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/management/jmxremote.password

Proof, we are tinkering with the JVM not with Glassfish settings.

jconsole conneted to remote server

jconsole conneted to remote server

2 thoughts on “Remote Glassfish V3.1 and the mystical JMX settings

  1. Pingback: Monitoring Glassfish V3.1.2 Options | The JavaDude Weblog

Leave a comment