Tuesday, 12 May 2009

How to Debug Glassfish with Eclipse | Chanchal Kumar

Chanchal Kumar writes:

Debugging Glassfish with Eclipse is a straightforward two step process (I admit that Eclipse has its own very difficult moments when even the straightforward isn't so straight anymore), nevertheless these two steps should take you forward:

1) Starting your glassfish in the debug mode is the first step. Here is a screenshot explaining what to do first:

In the image above, you see that in the Glassfish Admin Console, you need to tick the Enabled flag for Debug under JVM General Settings. Also notice that (by default) the debug options have a port sest to 9009. You need to inform Eclipse that this is the port it should use to connect to Glassfish.

2) In the next step, we open the debug dialog in eclipse (Run -> Open Debug Dialog), and configure our project to use the Glassfish in the Debug mode. Here is another screenshot explaining what to do:

Notice that you need to create a `New` when you right-click `Remote Java Application`, the project you selected in Eclipse is by default filled in or if you want you could change to the project you want to use. Enter the IP address of the host running Glassfish/Sailfin and the port number we configured in the first step i.e. 9009

That was all that is needed, you are set to rock the JVM now. I mentioned there are only two steps, the third one is perhaps too intuitive to be called a step; I shall mention it anyway that for debugging you need to turn on the debugging perspective as shown in this image:


  1. Thanks Chanchal, that was excellent.
    A small note: on some versions of Glassfish you'll need to restart the domain for the debug mode to accept connections.

  2. Hi Chanchal, very nice. Thanks!

  3. Hi Chanchal, the above steps are to debug sailfin in the single instance mode..Do you know how its done in case of cluster setup with several instance; In short what I am looking for is to start the entire cluster in debug mode.