无法从主机 Windows 7 上的 Eclipse 远程调试在 CentOS 虚拟机上运行的 Tomcat
设置
VMWare 虚拟机
- CentOS 5.5 64 位
- OpenJDK 64 位服务器 VM(版本 14.0-b16,混合模式)
- Tomcat 6.0
主机
- Windows 7 64 位
- Oracle/Sun JDK 1.6 面向 Java EE 开发人员的 64 位
- Eclipse Helios
问题
我的 eclipse远程 Java 应用程序具有以下连接属性:
Host: 192.168.94.133
Port: 8000
当我运行上述配置时,我得到:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
tomcat 日志中没有出现任何新内容。
但是当我从 Windows 盒子中进行 telnet 时:
bash-3.2$ telnet 192.168.94.133 8000
Trying 192.168.94.133...
Connected to 192.168.94.133.
Escape character is '^]'.
Connection closed by foreign host.
每次我尝试上述 telnet 时,tomcat 都会在日志中吐出以下内容:
Debugger failed to attach: timeout during handshake
由于 telnet 行为,我认为问题出在 Eclipse 中...我将不胜感激。
谢谢,
-戴夫
Setup
VMWare Virtual Machine
- CentOS 5.5 64-bit
- OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
- Tomcat 6.0
Host Machine
- Windows 7 64-bit
- Oracle/Sun JDK 1.6 64-bit
- Eclipse Helios for Java EE developers
Problem
My eclipse Remote Java Application has following connection properties:
Host: 192.168.94.133
Port: 8000
When I run the above configuration, I get:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
Nothing new comes out of tomcat's log.
But when I telnet from the windows box:
bash-3.2$ telnet 192.168.94.133 8000
Trying 192.168.94.133...
Connected to 192.168.94.133.
Escape character is '^]'.
Connection closed by foreign host.
Every time I try the above telnet, tomcat spits this out in the log:
Debugger failed to attach: timeout during handshake
Because of the telnet behavior, I think the issue is in Eclipse... I'd appreciate any help.
Thanks,
-Dave
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能正在尝试从 Eclipse 连接两次到端口 8000(没有注意到)。
显式切换到调试透视图(“窗口 - 打开透视图 - 调试”)并查看是否已连接。
You are probably trying to connect twice to port 8000 from Eclipse (without noticing).
Switch to the Debug Perspective explicitly ("Window - Open Perspective - Debug") and see if you are connected.
Tomcat 中所需的设置 1) 在 */tomcat/bin/ 下创建 setenv.sh 文件。该位置与catalina.sh 文件相同
2) 将以下内容放入其中。 export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
现在启动 Tomcat 服务器。启动后,请继续执行以下步骤。
Eclipse 中所需的设置
3)在 Eclipse 中,转到 Windows--> 首选项-->常规-->网络连接-->主动提供者应该是直接的。改完后直接重启eclipse。
4)在eclipse中右键单击项目并调试为->调试配置->远程java应用程序->创建新配置。填写以下字段名称:根据您的意愿项目:选择您需要调试的项目。连接类型:标准套接字连接主机:本地主机端口:8000(应与第 2 点中提到的相同)然后单击调试。
调试将从端口 8000 开始。现在您可以通过保留断点进行验证。
Settings required in Tomcat 1)Create setenv.sh file under */tomcat/bin/. The location will be same as the catalina.sh file
2)Place the below content inside it. export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
Now start the Tomcat server. Once it is started please proceed with the below steps.
Settings required in Eclipse
3)In Eclipse go to Windows-->Preference--> General-->Network Connection --> Active Provider should be Direct. After changing to direct restart the eclipse.
4)In eclipse right click on project and debug as ->debug configuration ->Remote java application ->Create new configuration. Fill the below fields Name: as your wish Project:Select the project which you need to debug. ConnectionType: Standard socket attach Host: Localhost Port: 8000(It should be same as mentioned in point 2) Then click debug.
The debug will start at port 8000. Now you can verify by keeping breakpoints.