JPDA and Set up Tomcat for Remote Debugging

FangwenYu發表於2013-08-15

* 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了。

相關文章