Open debug mode for Tomcat and use Eclipse to remote debug the application
来源:互联网 发布:网络啦德玛西亚歌曲 编辑:程序博客网 时间:2024/05/16 10:42
Today I tried to use remote debugging with Eclipse and Tomcat.
I usually use a Tomcat Sysdeo Plugin to run Tomcat inside Eclipse, but today I faced remote debugging.
To run tomcat in remote debugging you can start it with command
catalina jpda start
But this will start remote debugging using shared memory, and Eclipse, as far as I know, does not support shared memory as transport for deubugging.
The alternative is to use a socket as transport for JPDA.
You simply set some enviroment variable that will be checked by catalina startup script, as in following example:
set JPDA_TRANSPORT=dt_socketset JPDA_ADDRESS=5050... then you can run ...D:/Java/jakarta-tomcat-5.5.7/bin>catalina jpda run...or...D:/Java/jakarta-tomcat-5.5.7/bin>catalina jpda start
This tells catalina script to use socket transport for debugging and to listen on port 5050. If you don't specify the port, it will be assigned randomly.
When you start tomcat, you'll see some messages on console saying that debugging socket is listening:
D:/Java/jakarta-tomcat-5.5.7/bin>catalina jpda runUsing CATALINA_BASE: D:/Java/jakarta-tomcat-5.5.7Using CATALINA_HOME: D:/Java/jakarta-tomcat-5.5.7Using CATALINA_TMPDIR: D:/Java/jakarta-tomcat-5.5.7/tempUsing JAVA_HOME: d:/Java/jdk1.5.0_04Listening for transport dt_socket at address: 50504-ott-2005 18.26.11 org.apache.coyote.http11.Http11Protocol initINFO: Initializing Coyote HTTP/1.1 on http-80804-ott-2005 18.26.11 org.apache.catalina.startup.Catalina loadINFO: Initialization processed in 1162 ms4-ott-2005 18.26.11 org.apache.catalina.core.StandardService startINFO: Starting service Catalina4-ott-2005 18.26.11 org.apache.catalina.core.StandardEngine startINFO: Starting Servlet Engine: Apache Tomcat/5.5.74-ott-2005 18.26.11 org.apache.catalina.core.StandardHost start
Now it's time to connect to that socket using Eclipse: see following picture.
On "Connection Properties" you can configure a remote VM that you want to debug. Then place your breakpoints and run the shown launch configuration.
Shared memory is easier to be used: with tomcat you don't have to set up environment variables, and for IDE supporting it (I used this with IntelliJ), you only need to specify the name of the shared space. This won't work if the VM to debug is on a remote computer but can be helpful anyway. I tried to find shared memory support in Eclipse but I didn' find it, and I believe it doesn't have.
Remote debugging is more useful when you have to attach to a running instance on a remote server on which the bug is alive. Shared memory support lack is not that problem.
One thing that you cannot do running programs inside Eclipse under Windows is to get a Thread dump. On Windows you can get a Thread Dump pressing CTRL+Break in the DOS console, but this doesn't work on Eclipse console. On Linux you can use "kill -3", and I think this work even running processes in Eclipse. Maybe it's possible also in Windows, using some esotic tool, but I don' know... also I don't know if Windows supports several kill signals.
- Open debug mode for Tomcat and use Eclipse to remote debug the application
- Tomcat and eclipse remote debug
- eclipse remote debug tomcat
- Remote Java Application Debug & Eclipse
- Remote debug Tomcat from Eclipse
- Eclipse remote debug for maven
- Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically a
- Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically a
- eclipse remote debug with tomcat 的配置
- 用Eclipse远程调试(Remote debug)Tomcat
- Eclipse Remote Debug, specially for Applet
- remote debug with Tomcat
- Tomcat Remote Debug
- Tomcat remote debug
- how to use the dynamic debug
- Eclipse remote debug introduction
- eclipse remote debug
- eclipse remote debug tomcat8
- JSF框架中使用的设计模式介绍
- 诡谲和难以捉摸的C++语言风格流变史
- Rad & none_RAD
- [java] a simple Applet program
- 英特尔与诺基亚结盟利弊分析
- Open debug mode for Tomcat and use Eclipse to remote debug the application
- 在使用Java语言开发时要注意的性能设计
- Asp.net2.0 配置log4net 具体方法
- jjjjjj
- sql数据显示问题
- 解决VS2008中MFC静态编译出来的文件太大问题
- JSF的工作方式
- 等
- 奋斗经典语录