Posts Tagged ‘jdb’

How to enable Eclipse/Glassfish remote debugging

Monday, March 22nd, 2010

You would normally enable jdb by adding debug options into your Java start up command by attaching debugging into JVM process, like the following:

DEBUG_OPTS=”-Xdebug -Xrunjdwp:transport= dt_socket,address=1044,server=y,suspend
=n”

You would consider adding this into your Glassfish’s(V2, in my case) start up script asadmin as below:

“$AS_JAVA”/bin/java “$DEBUG_OPTS” -Dcom.sun.aas.instanceName=server -Djava.libra
ry.path=”$AS_NSS”:”$AS_INSTALL/lib”:”$AS_ICU_LIB” -Dcom.sun.aas.configRoot=”$AS_
CONFIG” -Djava.endorsed.dirs=”$AS_INSTALL/lib/endorsed” -Dcom.sun.aas.processLau
ncher=”SE” -cp “$AS_DERBY_INSTALL/lib/derby.jar”:”$AS_INSTALL/jbi/lib/jbi-admin-
cli.jar”:”$AS_INSTALL/jbi/lib/jbi-admin-common.jar”:”$AS_INSTALL/lib”:”$AS_INSTA
LL/lib/appserv-rt.jar”:”$AS_INSTALL/lib/appserv-ext.jar”:”$AS_INSTALL/lib/javaee
.jar”:”$AS_INSTALL/lib/appserv-se.jar”:”$AS_INSTALL/lib/admin-cli.jar”:”$AS_INST
ALL/lib/appserv-admin.jar”:”$AS_INSTALL/lib/commons-launcher.jar”:”$AS_INSTALL/l
ib/install/applications/jmsra/imqjmsra.jar” -Dcom.sun.appserv.admin.pluggable.fe
atures=com.sun.enterprise.ee.admin.pluggable.EEClientPluggableFeatureImpl com.su
n.enterprise.cli.framework.CLIMain “${@}”

Actually this will not work.

You have to log into the Glassfish admin console, under:

Application server

JVM General Settings

Debug
Enabled (check it)

Hit save

Restart Glassfish.

You’ll see Glassfish start up script spits the following message:

Listening for transport dt_socket at address: 9009
Application server is listening at address 9009 for debugger to attach using transport dt_socket

It started to listen at port 9009 by default instead of 1044.

You’ll configure your Eclipse accordingly to do remote debugging. Remember the port number 9009 instead of 1044.