Sunday, January 30, 2011

Running GlassFish with JRockit

Since GlassFish 3.0.1 the JDK support was extended. You now also could run GlassFish with Oracle JRockit 6 Update 17 R28.0.0+. This is a great choice in general and I must admit, that this announcement slipped through and missed my attention until today.

Getting started
Get the latest GlassFish 3.0.1 and the latest Oracle JRockit 28.1. Start with installing the JRockit to a suitable location. After that, start the GlassFish installer and do the same. Select the JRockit installation folder if you are asked to select the JDK. Finish the GlassFish installation. and change to %GF_HOME$/bin and type asadmin start-domain.
You will see something like this:
Waiting for DAS to start .Error starting domain: domain1.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

[WARN ][jrockit] MaxPermSize=192m ignored: Not a valid option for JRockit
[WARN ][jrockit] NewRatio=2 ignored: Not a valid option for JRockit
Could not create the Java virtual machine.
Unknown option or illegal argument: -XX:+LogVMOutput.
Please check for incorrect spelling or review documentation of startup options.

Configure your Domain
Both JVM options are invalid for JRockit. So you have to get a hand on your %GF_HOME%/glassfish/domains/domain1/config/domain.xml and comment out or remove the following three lines in the <java-config> section:

<jvm-options>-XX:+LogVMOutput</jvm-options>
<jvm-options>-XX:MaxPermSize=192m</jvm-options>
<jvm-options>-XX:LogFile=${com.sun.aas.instanceRoot}/logs/jvm.log</jvm-options>
After that try restarting your domain and you will see, it works.
If you run the admin console and select "Enterprise Server > JVM Report" you will see, that the Oracle JRockit is now used.
This seems to be a know issue and will be fixed in the next GlassFish 3.1 release.

Why JRockit?
There are a couple of reasons. It's simple the most powerful JVM on earth. But my favorite is the Mission Control Tooling. includes tools to monitor, manage, profile, and eliminate memory leaks in your Java application. You can simply browse any resources on the server and have a very handy tooling for identifying problems. The most powerful thing is the Flight Recording feature. You can monitor your JVM like a blackbox and collect runtime information with minimal overhead. The flight recording option is enabled by default. You simple need to take your probe for as long as you need it and analyze it with the JRMC.
JRockit Flight Recorder does all this by being tightly integrated into the JVM and by being very conscious of its performance overhead. It provides a wealth of information on the inner workings of the JVM as well as on the Java program running in the JVM. You can use this information for profiling and for root cause analysis of problems. It can be enabled at all times, without causing performance overhead—even in heavily loaded, live production environments.
If you are looking for more details also compare my Flight Recorder post. There are some more experimental features available which you could install by simply selecting "Help > Install Plugins". A WebLogic plugin is available. I would love to have a separate for GlassFish also.