Despite running JVM supposedly being rock-solid and stable I see enough JVM who cant take the load, most likely to non-optimal settings, throwing heap dumps.
A while ago I struggled to open Thread Dumps I can open heap dumps with VisualVM (Version 1.3.7 at the time of writing)
Heap Dump File
Beware, with significant heap dump files (in my sample 700MB) it can take quite a while to open or review the results. Open thread dump list took a good 10 minutes.
Once you get into a production like stage with more data volume, more users, etc. you will find yourself pretty fast in the situation where Glassfish gets some hickups or slowness. An expected situation if you did not change the default parameters out of the box which are chosen to make Glassfish to run even on a small box.
We ran into some kind of concurrency problems with JDBC pools and thread where Glassfish appeared to be hanging. One approach is to create thread dumps for the JVM.
With Glassfish we have a few options:
Run jps which returns you the list of applications running a JVM, choose the PID and execute
jstack <PID> or jstack -F <PID> > td.log
Go the Glassfish_HOME/bin folder and execute ./asadmin --user admin generate-jvm-report --type=thread > threaddump.txt
kill -3 <PID>
Supposed to create a dump in the default log folder of Glassfish. Doesnt work for me.
With the (or better more than 1) file at hand you can evaluate them by hand or use some of the tools around. I am still struggling to make the tool analyzing my dumps. They simply open the files like a editor.
There are 2 crucial phases you want to look under the hood of your running Glassfish or inside the JVM underneath: Performance Tuning and Health Monitoring during production.
With JMX (Java Management Extensions, Wikipedia) at hand, there are a few options to choose from.
The graphical monitoring tool is great for local deployment, it allows you to connect to a JVM on the same host or a remote host. It creates line graphs for your for all relevant from the moment you connect, it is perfect to observe a server while you do some testing or other actions, though it does not record any values while you are not connected. I have a hard time to get it running on a remote server and I do not favour the ‘open’ approach (see previous blog entry) which allows anyone to access the JVM with the disabled authentication settings. I also had situations where the JVM was frozen and it was no longer possible to access the JVM for monitoring, here I would rather have snapshots before the problem started together with server.log.
Glassfish Rest Interface
Note: You need to enable the areas you want to monitor with the admin console (or the asadmin command line) because per default all are OFF. Continue reading →
Note: you need to re-deploy the resource adapter with version 5.7 and check all connector settings.
It works fine with Glassfish 220.127.116.11 and Java JDK 1.7.07
I had issues with the firewall due to fact ActiveQM uses a fix registration port for JMX but dynamic ports for the communication port. The web-console was not accessible. “Exception occurred while processing this request, check the log for more information!”
[#|2012-10-18T07:42:09.249+0000|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=73;_ThreadName=Thread-2;|StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
java.net.ConnectException: Connection timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
There are ways to configure this for a standalone ActiveMQ instance with the parameters connectorPort and rmiServerPort but I didnt find out yet how to do this with the embedded version.
As a workaround I changed this setting -Djava.rmi.server.hostname from my hostname to localhost. -Djava.rmi.server.hostname=localhost
I am quite OK with the build-in JMS in Glassfish (OpenMQ), as long you dont want to access queues from external applications or you need an admin console to easily create, delete queues, send messages and browse the queues. ActiveMQ is a good alternative. Unfortunately we could not find any end2end description hot to get the couple Glassfish-ActiveMQ up and running (under Linux, Windows should be a quite similar affair).
This tutorial describes how to install and configure ActiveMQ as embedded JMS broker, and connect a MDB to it.
Running Glassfish 3.1 instance (or later).
Download the current ActiveMQ package
At the time of writing it is 5.5.0 (apache-activemq-5.5.0-bin.tar.gz)