Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > Java > tomcat 远程debug
【标  题】:tomcat 远程debug
【关键字】:tomcat,debug
【来  源】:http://www.blogjava.net/hama/archive/2007/02/06/98158.html

tomcat 远程debug

Your Ad Here

How do I configure Tomcat to support remote debugging?

The short answer is to add the following options when the JVM is started:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
There are a number of ways you can do this depending on how you normally start Tomcat:

  • Set environment variables JPDA_ADDRESS=8000 and JPDA_TRANSPORT=dt_socket and then start tomcat using catalina jpda start(sh catalina.sh jpda start).
  • If you run Tomcat using service wrapper, check the documentation for the service to determine how to set the required JVM options.
  • If you start Tomcat from within an IDE, check the documentation for the IDE to determine how to set the required JVM options.

Using catalina start and CATALINA_OPTS

Alternatively, you can set the java program's command-line arguments for the JPDA settings. For Tomcat, you specify them in the CATALINA_OPTS environment variable and the catalina.sh or catalina.bat script adds the value of the environment variable to the java command that starts Tomcat; for example:

bash:

declare -x CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
$JWSDP_HOME/bin/catalina.sh start

csh:

setenv CATALINA_OPTS "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000"
$JWSDP_HOME/bin/catalina.sh start

Windows:

set JPDA_TRANSPORT=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
%JWSDP_HOME%\bin\catalina start
The port does not need to be set to 8000, it may be any value appropriate for your system.

Whilst this is very useful in development it should not be used in production because of both security and performance implications.


How do I remotely debug Tomcat using Eclipse?

This answer assumes that you have a project set up with all of the fixings and have some idea of what you're doing in this respect. If not then thats really outside the scope of this topic and more in the scope of you needing to go to eclipse.org and read up on how to use your ide, and maybe practice a little bit before you come back to this. We're also going to assume you have some idea of what a debugger is and how to use one.

Make sure tomcat is started and that your app is deployed and the sources, etc are all defined as resources in your app. If you have a servlet or something, set a breakpoint where its sure to hit on the next request. Go to "Run->Debug...". Click on "Remote Java Applications", then click "New". Type in the title and all. Notice that port 8000 from the Tomcat instructions. Save and run. Eclipse will connect to the VM that Tomcat is running under. Wow, that was easy! Now go type the url to submit to your servlet or whatever in your browser. Boom you hit the breakpoint right? Have fun!

《人月神化》读书笔记(1):【上一篇】
Ogre 分析系列完全篇:【下一篇】
【相关文章】
  • apache和tomcat的集成
  • Tomcat启动脚本学习心得-判断JAVA_HOME友好提示用户
  • 使用Eclipse远程调试发布在Tomcat上的Web应用
  • apache2.2 tomcat5.0 整合步骤(支持集群负载均衡)
  • 调试工具-DEBUG
  • JAVA1.5+TOMCAT+Eeclipse 的配置
  • Remote Kernel Debugging with WinDbg
  • Using the Windows Debugger: Some Handy/Fun/Clever Debugger Commands
  • Tomcat的详细配置手册
  • Windows Native Debugging Internals
  • 【随机文章】
  • 解析C++汇编代码-局部变量空间分配及程序栈操作
  • Dofile 上传,下载,清除
  • some drawings of transistor transmitter design
  • AVSLive--支持avs的live cd
  • 嵌入式linux移植过程中“串口终端”问题解决方案
  • CSS解决未知高度垂直居中[摘自蓝色经典]
  • 把书中的SQL查询语误句调一下
  • 修复GRUB引导菜单
  • 今天也追星,领了一张“天仙妹妹”的签名明信片,有图[手机照片]
  • FreeBSD下VI编辑器的使用
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.