Java Chatter and Random Nagging

Thursday, October 26, 2006

Tomcat Remote Debugging and Eclipse

People not using Eclipse WTP (poor fools) but using Eclipse, can take the following steps to enable Eclipse Debugging and Tomcat :
  1. Add the following line to the catalina.bat/.sh file ():

    set JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

    • Xdebug : start the jvm and listen for debugging connections.
    • Xrunjdwp... : the info on how to connect to do remote debugging.
    • server=y : start in server mode (i.e. wait for connections, don't go out looking to connect.
    • transport=dt_socked : use sockets to connect.
    • address=8000 : the port to connect to.
    • suspend=n : don't wait for a debugger to tell you what to do, go ahead and launch.
    • Explanation of the options : http://java.sys-con.com/read/44918.htm
  2. Start your Tomcat Server.
  3. In Eclipse, choose Debug... Remote Java application (standard socket attach) localhost 8000.




Note : A very similar approach can be taken to enable 'real' remot debugging of a distant host (not localhost).

0 Comments:

Post a Comment

<< Home