Friday, March 9, 2012

Remote Debugging With Eclipse


Remote Debugging With Eclipse

Using JPDA (Java Planform Debugger Architecture) we can Debug Remote Java Applications

Prerequisites

(i)In Eclipse V3.4 (Ganymede), the socket listening connector has been added to the Remote Java Application launch-configuration type

(ii)To use remote debugging, Java Virtual Machine (JVM) V5.0 or later must be used.


To Debug We have to Configure Followings

A) How To Debug a Remote Java Application with JPDA

We have to Pass Debugging Parameters Like this.

$>java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -jar Tested.jar

TIPS:

1) JDWP-Java Debug Wire Protocol
2) address=8000 is default we can change

3) suspend=y will ensure that that application will not start running until eclipse connect it on speicified debug port.It also important to note
    That application must be start before eclipse tries to connect it other wise Eclipse will throw error "Failed to connect to remote VM.  Connection refused" or "Connection refused: connect"

4) suspend parameter takes value as "y" or "n". so if you want to debug the process from start set this parameter as  "suspend=y" and your Java application will wait until Eclipse remotely connect to it. Otherwise if you want to run your program and later want eclipse to be connected that set this as "suspend=n" so your java application will run normally and after eclipse remotely connected to it, it will stop on breakpoints.

5)server-If the value is y, the target application listens for a debugger application to attach. Otherwise, it attaches to a debugger application at the specified address.
6)transport
Generally, socket transport is used. But shared-memory transport can also be used on the Windows platform, if available.

7)Target VM acts as a debug server
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000

8) Target VM acts as a debug client
-Xdebug -Xrunjdwp:transport=dt_socket,address=127.0.0.1:8000


B) How To Debug  Remote Web Applications on Tomcat with JPDA


Insted of Starting Tomcat's default startup we use caralina.sh with additional debug parameters jpda {start|stop}

$>./catalina.sh jpda start
$>./catalina.sh jpda stop

No comments:

Post a Comment