Java Tomcat 启动时忽略 jpda 选项进行调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18717831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Tomcat startup ignoring jpda option for debug
提问by clairebones
I am attempting to run Tomcat 7 in debug mode. If I type ./catalina.sh jpda start
tomcat runs as though the jpda option is not there and outputs:
我正在尝试在调试模式下运行 Tomcat 7。如果我输入./catalina.sh jpda start
tomcat 运行,好像 jpda 选项不存在并输出:
Michaels-MacBook-Pro:bin clairewilgar$ ./catalina.sh jpda start
Using CATALINA_BASE: /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS
Using CATALINA_HOME: /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS
Using CATALINA_TMPDIR: /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/temp
Using JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH: /Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/bin/bootstrap.jar:/Users/clairewilgar/Downloads/apache-tomcat-7.0.42-MIS/bin/tomcat-juli.jar
and does not change my CATALINA_OPTS or anything. If I attempt to connect via Eclipse I get the error
并且不会改变我的 CATALINA_OPTS 或任何东西。如果我尝试通过 Eclipse 连接,我会收到错误
'Launching workflow' has encountered a problem. Failed to connect to remote VM. Connection refused.
“启动工作流”遇到问题。无法连接到远程 VM。拒绝连接。
I have tried changing the port to jpda port to 8001 to no success, I have tried declaring the JPDA options in the terminal before calling catalina.sh but that makes no difference. My catalina.sh JPDA lines are as follows:
我尝试将端口更改为 jpda 端口到 8001 没有成功,我尝试在调用 catalina.sh 之前在终端中声明 JPDA 选项,但这没有区别。我的 catalina.sh JPDA 行如下:
if [ "" = "jpda" ] ; then
if [ -z "$JPDA_TRANSPORT" ]; then
JPDA_TRANSPORT="dt_socket"
fi
if [ -z "$JPDA_ADDRESS" ]; then
JPDA_ADDRESS="8000"
fi
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
if [ -z "$JPDA_OPTS" ]; then
JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
fi
CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
shift
fi
Are there any other reasons why JPDA might not run? I'm using OSX (Mountain Lion) if there's anything related to that that I may have missed. Thanks in advance.
JPDA 可能无法运行是否还有其他原因?如果有任何与我可能错过的相关的东西,我正在使用 OSX(Mountain Lion)。提前致谢。
EDIT:My catalina.out file for running ./catalina.sh jpda start
is at http://pastebin.com/Z4GSvckr
编辑:我用于运行的 catalina.out 文件./catalina.sh jpda start
位于http://pastebin.com/Z4GSvckr
回答by Qben
Same issue if you start it from startup.sh
? Remeber you might have to edit startup.sh
to make it call catalina.sh
with the jpda
parameter.
如果从startup.sh
? 请记住,您可能需要编辑startup.sh
以使其catalina.sh
使用jpda
参数进行调用。
Have you tried to set the variables manually? I never had this issue at my end but I tend to do something like described in this wiki.
您是否尝试过手动设置变量?我最后从来没有遇到过这个问题,但我倾向于做这个wiki 中描述的事情。
Also, if the variables above are already set in your environment they will not be reset in the catalina.sh
script (-z
).
此外,如果上述变量已在您的环境中设置,它们将不会在catalina.sh
脚本 ( -z
) 中重置。
You could also try to add setup.sh
in the bin
folder containing:
您还可以尝试添加包含以下内容setup.sh
的bin
文件夹:
JPDA_TRANSPORT="dt_socket"
JPDA_ADDRESS="8000"
JPDA_SUSPEND="n"
JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"
CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS"
With this change you can simply start tomcat using startup.sh start
.
通过此更改,您可以简单地使用startup.sh start
.
回答by Titi Wangsa Bin Damhore
It may be an IPv4 vs IPv6 issue.
这可能是 IPv4 与 IPv6 的问题。
netstat -an | grep 8000
I once had a problem where I could not connect to "localhost" port 13306, but could connect to "127.0.0.1" port 13306
我曾经遇到过一个问题,我无法连接到“localhost”端口 13306,但可以连接到“127.0.0.1”端口 13306
localhost was mapped to an IPv6 address while the process was listening to an IPv4 address
本地主机被映射到 IPv6 地址,而进程正在侦听 IPv4 地址
回答by Eyal leshem
you can change this line in the catlina.sh:
您可以在 catlina.sh 中更改这一行:
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
to :
到 :
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="y"
fi
or set the env-var "JPDA_SUSPEND" to "y" - before calling the catalina.sh
或在调用 catalina.sh 之前将 env-var "JPDA_SUSPEND" 设置为 "y"
回答by borowis
I had the same problem, as it turned out my startup.sh file contained the following lines:
我遇到了同样的问题,因为我的 startup.sh 文件包含以下几行:
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
Therefore command ./startup.sh jpda start was sent to catalina.sh as start jpda start and therefore debugging options were ignored, so I had to change this line to
因此命令 ./startup.sh jpda start 被发送到 catalina.sh 作为 start jpda start 并且因此调试选项被忽略,所以我不得不将此行更改为
exec "$PRGDIR"/"$EXECUTABLE" "$@"
Regards, Borys
问候,鲍里斯
回答by jcarlosriveraavila
Change the last line of this file: "startup.sh"
("startup.bat"
if you are using Windows)
更改此文件的最后一行:"startup.sh"
("startup.bat"
如果你使用的是Windows)
Instead of using this:
而不是使用这个:
exec "$PRGDIR"/"$EXECUTABLE" start "$@"
Use this:
用这个:
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@"