Thursday, January 29, 2009

J2EE Remote debugging

To enable remote debugging both server and client needs to be configured. The server should be enabled to listen to debug connections and client should open a connection and interact with server for debug information.

On the Server:
Below are the jvm parameters which have to be passed to any server to enable debugging.
-Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7010
Below are the meaning of each parameter
Xdebug- Enables debugging (start the jvm and listen to debug connections)
Xnoagent- Disables VM support for old jdb. Basically it disables the old way of communicating with the debugee. It is optional.
Xrunjdwp-Makes use of transport and the JDWP protocol to communicate with a separate debugger application. The sub-options specify the details required like
transport=dt_socket specifies to use socket connection on the port specified by the address.
transport=dt_shmem uses available shared memory transport address.

On the Client: (Here it is eclipse)
Follow the steps below:
1. Open java perspective
2. Open the java class where you want to place breakpoint
3. Add breakpoint
4. Now Go to menu bar Run->Debug Configurations (In older versions I think it is Run->Open Debug Dialog).
5. Right click on the 'Remote Java Application' in the left section of popup window. select New.
6. The class and package would be automatically selected for you as you had opened the java file just before you opened debug configurations.
7. Give proper host and port as mentioned in the server above, Apply and click debug.
8. Once you click debug eclipse will try to connect to server on the port.
Now run the application and you will see that the the program control would stop at the breakpoint you just added when your breakpoint is reached in the program flow.

Learning programming

    Programming is an interesting world where you apply your skills to build a software program that comes into life when it is run on a com...