Debugging with Eclipse & JPDA


url:http://docs14.xnat.org/Debugging+with+Eclipse+%26+JPDA


Instrument Tomcat with JPDA

Method A: Modify Tomcat’s Startup

We will modify our Tomcat startup script to pass the JPDA parameter and environment variables, leaving JPDA running whenever we start Tomcat. From our experience, leaving JPDA running on a development machine has no noticeable performance impact (just make sure your JPDA port is properly firewalled).

On Linux/Mac modify your $TOMCAT_HOME/bin/startup.sh from

exec "$PRGDIR"/"$EXECUTABLE" start "$@"

to (feel free to change the port number):

JPDA_ADDRESS=8000
JPDA_TRANSPORT=dt_socket
echo "Starting with JDPA at $JPDA_ADDRESS"
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"

On Windows, modify your $TOMCAT_HOME/bin/startup.bat from

On Windows, modify your $TOMCAT_HOME/bin/startup.bat from

to

set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

You can now start Tomcat via startup.sh or startup.bat.

Method B: Single Use Environment Variables

If you do not want to modify Tomcat’s startup script, you can set the JPDA_ADDRESS, JPDA_TRANSPORT as environmental variables on the command line, then launch Tomcat via:

$TOMCAT_HOME/bin/catalina jpda start

Connect Tomcat to JPDA

Create a new Debug Configuration

这里写图片描述

Select New launch configuration

这里写图片描述

Configure the Launch Configuration

Set the Port to the JPDA_ADDRESS you set in startup file and make sure that xnat is selected as the project to debug.
这里写图片描述

Set a Breakpoint & Debug

You can set breakpoints anywhere in the code. Navigate the website, when the breakpoint is hit, you will be prompted to enter the Debug Perspective.
这里写图片描述
The Debug Perspective allows stepping through the source as well as examining the state of variables.
这里写图片描述

Debugging Applets with JPDA

You can also use JPDA to debug applets running in the browser. To enable JPDA, go to the Java Control Panel > Java > Java Runtime Settings > View > User > Runtime Parameters

And add the options to enable debugging:

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

You can set the address to any free port (we are using 8000 in this example).

If you need to debug the applet startup, classloading, etc, set suspend to y. When you access an applet page, the browser will appear to freeze as the JVM immediately gets suspended waiting for a debugger to connect.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值