View RSS Feed

My Java Tips

Enabling Debugging

Rate this Entry
by , 10-25-2011 at 07:08 PM (1673 Views)
There are different ways to enable debugging in Glassfish. Let's start with enabling debugging using administration console.

To enable debugging follow the following after each server restart:

- Login to the Administration Console using web browser:
For example:http://localhost:4848/asadmin

- Go to the Application Server page.

- Select the JVM Settings tab and the General option.

- Check the Debug Enabled box.

- 1044 is the default port. To specify different port, specify address=port_number in the Debug Options field.

- If you wish to add JPDA options, add any desired JPDA debugging options in Debug Options. See JPDA Options.

- Hit the Save button.

Its done.

You may also enable debugging by editing the domain.xml file.

Set the following attributes of the java-config element in the domain.xml file:

- Set debug-enabled="true" to turn on debugging.
- Default port is: 1044. To specify different post, (to attach the JVM to a debugger), specify address=port_number in the debug-options attribute.
- Add any desired JPDA debugging options in the debug-options attribute.

Use --debug option while starting the server.

Java Code:
<pre lang="java">
asadmin start-domain --debug [domain_name]</pre>
After that you may attach to the server from the debugger at its default JPDA port(1044)
Java Code:
<pre lang="java">
jdb -connect com.sun.jdi.SocketAttach:port=1044</pre>
A good feature is that you can enable debugging even if you didn't use --debug option while starting the server.
This is done by setting the server to automatically start up in debug mode using:

- Administration Console
- Editing the domain.xml File

Submit "Enabling Debugging" to Facebook Submit "Enabling Debugging" to Digg Submit "Enabling Debugging" to Submit "Enabling Debugging" to StumbleUpon Submit "Enabling Debugging" to Google

Tags: None Add / Edit Tags