Java Platform Debugger Architecture(JPDA:Java平台调试架构) 由Java虚拟机后端和调试平台前端组成
tomcat可以通过jpda进行远程调试。可以修改startup.bat(linux下是startup.sh)或者是改catalia.bat
( linux下是catalia.sh) 来实现;
不改文件进行远程调试,可以通过命令"catalia.bat jpda start",用调试状态启动tomcat,
linux则是"./catalia.sh jpda start"。看catalia.bat 和 catalia.sh的区别,大致相同jpda参数是
JPDA_TRANSPORT (Optional) JPDA transport used when the "jpda start"
command is executed. The default is "dt_socket".
JPDA_ADDRESS (Optional) Java runtime options used when the "jpda start"
command is executed. The default is 8000.
JPDA_SUSPEND (Optional) Java runtime options used when the "jpda start"
command is executed. Specifies whether JVM should suspend
execution immediately after startup. Default is "n".
这里默认的jpda端口号为8000
D:\csp-tomcat-6.0.35\bin>catalina.bat /?
Using CATALINA_BASE: "D:\csp-tomcat-6.0.35"
Using CATALINA_HOME: "D:\csp-tomcat-6.0.35"
Using CATALINA_TMPDIR: "D:\csp-tomcat-6.0.35\temp"
Using JRE_HOME: ""
Using CLASSPATH: "D:\csp-tomcat-6.0.35\bin\bootstrap.jar"
Usage: catalina ( commands ... )
commands:
debug Start Catalina in a debugger
debug -security Debug Catalina with a security manager
jpda start Start Catalina under JPDA debugger
run Start Catalina in the current window
run -security Start in the current window with security manager
start Start Catalina in a separate window
start -security Start in a separate window with security manager
stop Stop Catalina
version What version of tomcat are you running?
很显然,这里的启动参数都说明了,一种启动方式:
|
catalina.bat jpda start <--|
1) 找到eclipse --> open debug dialog -->remote java application
2) 如果在要调试的代码前打了断点,双击remote java application时候会自动关联project
3) 如果没有自动关联,双击new一个
4) project,待调试的工程,connection type --> standard socket attach
5) connection properties: host:远程服务器的IP,port为catalina中配置的,
如果是catalina.bat jpda start这个port会在控制台显示出来的;
if not ""%1"" == ""jpda"" goto noJpda
set JPDA=jpda
if not "%JPDA_TRANSPORT%" == "" goto gotJpdaTransport
set JPDA_TRANSPORT=dt_socket
:gotJpdaTransport
if not "%JPDA_ADDRESS%" == "" goto gotJpdaAddress
set JPDA_ADDRESS=8000
有时候,要认真观察下下列参数的配置,出错大致是这里的参数有问题:
set _RUNJAVA="%JRE_HOME%\bin\java"
set _RUNJDB="%JAVA_HOME%\bin\jdb"
rem set #JAVA_OPTS=%JAVA_OPTS% -Xdebug -Xnoagent
-Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=3999
rem set JAVA_OPTS=%JAVA_OPTS% -Dcom.sun.management.jmxremote.port=52588
-Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
如果要远程调试,jar包的内容,要用到反编译工具,将反编译过来的代码丢在eclipse相同的目录下
不要动里面的代码,否则调试的时候代码的行数容易对不上,
[反编译后的代码行数和源文件的行数这是一个值得关注的问题]
BCompare对比工具 带扩展对比扩展工具:WindowsFormats.bcpkg,这个可以下载一个,直接在工具中看反编译后的的结果
1) tool --> import beyond compare settings -->select import file:
2) java class to source(V)
java jpda远程调试
最新推荐文章于 2023-02-25 13:06:27 发布