Thursday, 16 February 2012

Debug Tomcat Windows Service from Eclipse

1) Launch "Configure Tomcat" GUI
2) On Java tab under Java Options add the following 2 lines:
-Xdebug
-Xrunjdwp:transport=dt_socket,address=127.0.0.1:1044,server=y,suspend=n
alternatively, and preferred since Java 5.0, add the following line:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044


3) Restart Tomcat
4) In Eclipse go to Run->Debug Configurations.  Create a new Remote Java Configuration with the following settings:
Connection Type: Standard (Socket Attach)
Host: localhost
Port: 1044

Change server/port as appropriate.

To detach press this button:

Further Info:

> java -agentlib:jdwp=help

            Java Debugger JDWP Agent Library
            --------------------------------

(see http://java.sun.com/products/jpda for more information)

jdwp usage: java -agentlib:jdwp=[help]|[<option>=<value>, ...]

Option Name and Value            Description                       Default
---------------------            -----------                       -------
suspend=y|n                      wait on startup?                  y
transport=<name>                 transport spec                    none
address=<listen/attach address>  transport spec                    ""
server=y|n                       listen for debugger?              n
launch=<command line>            run debugger on event             none
onthrow=<exception name>         debug on throw                    none
onuncaught=y|n                   debug on any uncaught?            n
timeout=<timeout value>          for listen/attach in milliseconds n
mutf8=y|n                        output modified utf-8             n
quiet=y|n                        control over terminal messages    n
suspend=y tells the jvm to wait until debugger attached

Java Virtual Machine Tool Interface
More Info on JVM TI and writing agents
Java Platform Debugger Architecture (JPDA)
Java Debug Wire Protocol (JDWP)

No comments:

Post a Comment