JPDA and Set up Tomcat for Remote Debugging

* About JPDA (http://docs.oracle.com/javase/7/docs/technotes/guides/jpda/architecture.html)

JPDA: (Java Platform Debugger Architecture), the following diagram illustrates the architecture,

 

* How to setup Tomcat for remote debugging

It's quite simple to set up Tomcat for remote debugging. Open "bin/startup.bat", and you would find the following line at the end, 

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

 Just add "jpda" in frond of "start", that's

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

  

This will use the default "JPDA_TRANSPORT" and "JPDA_ADRESS" settings in "bin/catalina.bat",

** set JPDA_TRANSPORT = dt_socket

** set JPDA_ADDRESS=8000

After that, if you start tomcat, you would see the following line from the command console, 

Listening for transport dt_socket at address: 8000

 

Then you can set up your IDE (eclipse) to attach to the tomcat, 

  

除了远程debug之外,还有一种在开发阶段很方便的方式就是在eclipse里面直接指定tomcat的运行目录,然后在eclipse里面启动tomcat,这样就可以直接进行debug了。 

第一步: 设置eclipse 

window -> preference -> Tomcat, 然后入下图所示设置tomcat的目录 - 

第二步:进行调试 

如下图所示,可以在工具栏上直接双击tomcat的图标进行启动,然后就可以debug了。

原文地址:https://www.cnblogs.com/fangwenyu/p/3254786.html