简体   繁体   English

Eclipse错误:“无法连接到远程VM”

[英]Eclipse Error: “Failed to connect to remote VM”

I'm getting the following error when I start Debug from the Eclipse IDE. 从Eclipse IDE启动Debug时出现以下错误。

Message: “Failed to connect to remote VM. Connection Refused” 消息: “Failed to connect to remote VM. Connection Refused” “Failed to connect to remote VM. Connection Refused”

What could be the reason? 可能是什么原因?

Have you setup the remote VM to accept connections? 您是否设置了远程虚拟机以接受连接?

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=10000,suspend=n yourServer

Is there a firewall in the way? 是否有防火墙?

Are you specifying the correct host / port? 您是否指定了正确的主机/端口?

Are you connected to a VPN? 您是否已连接到VPN?

Remove your proxy from eclipse! 从Eclipse中删除您的代理!

Go to network Connections within General Preferences ( Windows -> Preferences ) and set "Active Provider" to "Direct" 转到“常规首选项”中的网络连接(Windows->“首选项”),并将“活动提供程序”设置为“直接”

删除代理

Reboot your Eclipse after that 之后重启您的Eclipse

使用0.0.0.0作为地址,以便可以从任何远程计算机进行连接,即:

-Xdebug -Xrunjdwp:transport=dt_socket,address=0.0.0.0:8000,server=y,suspend=y

David Citron is right -- if localhost is not resolving properly, it can cause this problem. David Citron是正确的-如果localhost无法正确解析,则可能导致此问题。 Here's how to test: 测试方法如下:

If it works when your PC is not connected to the net (no WiFi, no network cables). 如果您的PC 未连接到网络(没有WiFi,没有网络电缆)时仍然有效。 If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. 如果它在这些情况下确实有效 ,则可能是您需要确保地址已正确解析为localhost The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your PC. DDMS和adb.exe用于调试和与VM通信的消息必须正确解析为PC上的localhost (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.) (是的,奇怪的是,其他使用DDMS和adb的命令也能正常工作,但不能调试。似乎需要对DDMS或adb中的某些内容进行标准化,以便它们都在相同的条件下工作。)

If you need to make sure that things are resolving to localhost properly: 如果您需要确保一切都可以正确解析到localhost

1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts file: 1)确保此行位于/Windows/System32/drivers/etc/hosts文件中:

127.0.0.1  localhost

(you can have any amount of whitespace between "127.0.0.1" and "localhost") (您可以在“ 127.0.0.1”和“ localhost”之间使用任意数量的空格)

And -- as David Citron suggested -- make sure that the hosts file is valid and doesn't have cruft or errors in it. 并且-正如David Citron所建议的-确保hosts文件有效,并且其中没有内容或错误。

2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost . 2)如果这不起作用,那么您可能还需要将PC的IPv4地址添加到hosts文件,并将其解析为localhost (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line (您可以使用ipconfig命令找到您机器的IPv4地址。)例如,如果您机器的IPv4地址为192.168.1.100则可以添加以下行

192.168.1.100  localhost

to your hosts file. 到您的主机文件。 (You can add it below the "127.0.0.1 localhost" line in the file.) (您可以将其添加到文件中的“ 127.0.0.1 localhost”行下方。)

You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. 您可以使用netstat -b命令验证adb(如果正在运行,则为仿真器)是否正在侦听端口。 (Note that you need admin privileges for the -b option. I open a command window using "Run as Administrator.") (请注意,您需要-b选项的管理员权限。我使用“以管理员身份运行”打开命令窗口。)

add to your run script: 添加到您的运行脚本中:

export JPDA_ADDRESS=8787
export JPDA_TRANSPORT=dt_socket
export JPDA_HOST=localhost

JAVA_OPTS=$JAVA_OPTS -Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000
JAVA_OPTS=$JAVA_OPTS -Dsun.rmi.dgc.server.gcInterval=3600000
JAVA_OPTS=-Xdebug -Xnoagent -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n $JAVA_OPTS

Our development image only has the Tomcat service installation on it, so setting the environment variables, etc., didn't have any effect. 我们的开发映像仅安装了Tomcat服务,因此设置环境变量等没有任何效果。 If you need to do this through the Tomcat Windows service, there are a few things you'll need to be aware of: 如果您需要通过Tomcat Windows服务执行此操作,则需要注意以下几点:

  • David Citron's comment was the last bit that I needed to get my connection working. David Citron的评论是我保持联系所需的最后一点。 The hosts file on our machines has localhost commented out (it's supposedly resolved through the DNS, but that doesn't work for the debug connection). 我们机器上的hosts文件已将localhost注释掉(据说可以通过DNS进行解析,但这不适用于调试连接)。 I uncommented it and was able to connect. 我对此没有评论,并且能够连接。
  • If user access control is turned on, you'll need to use your admin credentials to access the services control panel or the Tomcat monitor app or whatever you're using to toggle the server state. 如果打开了用户访问控制,则需要使用管理员凭据来访问服务控制面板或Tomcat监视器应用程序,或用于切换服务器状态的任何内容。 The monitor app (documented here ) is probably the best, because you can both edit the server settings for the debug options and start and stop the server. Monitor应用程序( 在此处记录 )可能是最好的,因为您既可以编辑调试选项的服务器设置,也可以启动和停止服务器。
  • I thought that perhaps you would need to run Eclipse as an administrator to be able to terminate the Tomcat process, but you don't. 我认为也许您需要以管理员身份运行Eclipse才能终止Tomcat进程,但您不必这样做。 Once you have that remote attachment, you're able to work with the service up to termination. 有了该远程附件后,就可以使用该服务直至终止。

I solved it setting in Eclipse: 我在Eclipse中解决了它的设置:

Windows --> Preferences --> Java --> Debug --> Debugger timeout: 10000

Before I had set " Debugger timeout: 3000 " and I had problems with timeout. 在设置“ Debugger timeout: 3000 ”之前,我遇到了超时问题。

Possible Cause for this error: 此错误的可能原因:

  1. Your Remote Java Application is not running. 您的远程Java应用程序未运行。
  2. Check your Host and Port, many times these entries are not correct. 检查您的主机和端口,很多时候这些条目不正确。
  3. Firewall not allowing access to your remote port. 防火墙不允许访问您的远程端口。

You can also check this how to guide on eclipse remote debugging for more details. 您还可以检查此指南,以了解更多有关Eclipse远程调试的信息。

If you are using windows os then replace line in tomcat configuration Tomcat6\\bin\\startup.bat . 如果您使用的是Windows os,则替换tomcat配置Tomcat6\\bin\\startup.bat

Replace 更换

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

with

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

If you need to debug an application working on Tomcat, make sure that your Tomcat-folder/bin/startup.bat (if using windows) contains the following lines: 如果需要调试在Tomcat上运行的应用程序,请确保Tomcat-folder / bin / startup.bat (如果使用Windows)包含以下行:

set JPDA_TRANSPORT="dt_socket"
set JPDA_ADDRESS=8000

call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%

The following worked for me: edit the last line of tomcat startup.sh from 以下对我startup.sh从以下位置编辑tomcat startup.sh的最后一行:

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

to

export JPDA_ADDRESS=8000 export JPDA_TRANSPORT=dt_socket  
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$@" 

The solution that worked for me is weird 对我有用的解决方案很奇怪

  1. Simply remove the all the break points 只需删除所有断点
  2. Restart tomcat in debug mode (using catalina.sh jpda start) 在调试模式下重新启动tomcat(使用catalina.sh jpda start)
  3. Now try to connect and it worked!!!! 现在尝试连接并成功!!!!

Another possibility is that the debug agent is binding to the wrong network interface. 另一种可能性是调试代理绑定到错误的网络接口。

I've just seen this when trying to debug a Windows 10 JVM inside a VirtualBox VM, and I'm trying to connect from Eclipse running on the VirtualBox host. 在尝试调试VirtualBox VM内的Windows 10 JVM时,我已经看到了这一点,并且正在尝试从VirtualBox主机上运行的Eclipse连接。 In my case, the agent only bound to the 127.0.0.1 interface. 在我的情况下,代理仅绑定到127.0.0.1接口。

To fix, you can qualify the address including the IP of the interface you want to bind to. 要解决此问题,您可以限定address包括要绑定的接口的IP)。 For example: 例如:

java -agentlib:jdwp=transport=dt_socket,server=y,address=192.168.0.5:8000,suspend=n <other arguments>

I had the problem with Tomcat running on Ubuntu. 我在Ubuntu上运行Tomcat时遇到问题。 The issue was selinux was enabled and for some reason it would not let Eclipse connect to the debugging port. 问题是启用了selinux,由于某种原因,它不允许Eclipse连接到调试端口。 Disabling selinux or putting it in permissive mode solved the issue for me. 禁用selinux或将其置于宽松模式对我来说解决了这个问题。

I get this error for Weblogic after i installed Quicktime and removing QTJava.zip from classpath solves the problem. 在我安装Quicktime并从类路径中删除QTJava.zip之后,我就收到了Weblogic的此错误,此问题已解决。

https://blogs.oracle.com/adfjdev/entry/java_jre7_lib_ext_qtjava https://blogs.oracle.com/adfjdev/entry/java_jre7_lib_ext_qtjava

Increase the memory value of the properties 增加属性的内存值

  • MEM_PERM_SIZE_64BIT
  • MEM_MAX_PERM_SIZE_64BIT

in setDomainEnv.cmd file from %weblogic_home%\\user_projects\\domains\\your_domain\\bin %weblogic_home%\\user_projects\\domains\\your_domain\\bin中的setDomainEnv.cmd文件中

I'll add one more possible solution, if you're running this on a virtual machine (vmware, etc.) , some other process on the host or other VM could already have the port you're trying to connect with. 如果要在虚拟机(vmware等)上运行该解决方案,我将添加另一个可能的解决方案,主机或其他VM上的其他进程可能已经具有您要尝试连接的端口。 Either stop that other process or choose another port. 停止其他进程或选择其他端口。

Create setenv.bat file in nib folder of Tomcat. 在Tomcat的nib文件夹中创建setenv.bat文件。 Add SET JPDA_ADDRESS = 8787 ; 添加SET JPDA_ADDRESS = 8787; Override the jpda port Open cmd, go to bin folder of Tomcat and Start tomcat using catalina jpda start Set up a debug point on eclipse Next compile your project. 覆盖jpda端口打开cmd,转到Tomcat的bin文件夹,然后使用catalina jpda start启动tomcat。在eclipse上设置调试点接下来,编译项目。 Check localhost:8080/ Deploy the war or jar under webapps folder and this must deploy war on Tomcat. 检查localhost:8080 /将war或jar部署在webapps文件夹下,这必须在Tomcat上部署war。 Then send the request. 然后发送请求。 the debug point will get hit NOTE : Don't edit catalina.bat file. 注意:不要编辑catalina.bat文件。 make changes in setenv.bat file 在setenv.bat文件中进行更改

If you are using Jboss: 如果您使用的是Jboss:

change in the file jboss7.1.1\\bin\\standalone.conf.bat the line: 在文件jboss7.1.1 \\ bin \\ standalone.conf.bat中更改以下行:

rem set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

to: 至:

set "JAVA_OPTS=%JAVA_OPTS% -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"

I tried several things mentioned here, but the below method worked for me: 我尝试了这里提到的几件事,但是以下方法对我有用:

Go to Debug Console of Eclipse, where you will find the name of the process which is already existing there. 转到Eclipse的Debug Console,您将在其中找到已经存在的进程的名称。 Right click on that process and select "Terminate and Remove", this will terminate the process. 右键单击该过程,然后选择“终止并删除”,这将终止该过程。 Now try initiating the process again and it will work. 现在,尝试再次启动该过程,它将起作用。

In my case i turn Windows Firewall off 在我来说,我关闭 Windows Firewall

1- Open Windows Firewall by clicking the Start button Picture of the Start button, and then clicking Control Panel. 1-通过单击“开始”按钮“开始”按钮的图片,然后单击“控制面板”,打开Windows防火墙。 In the search box, type firewall, and then click Windows Firewall. 在搜索框中,键入防火墙,然后单击Windows防火墙。

2- Click Turn Windows Firewall on or off. 2-单击“打开或关闭Windows防火墙”。 Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation. 需要管理员权限如果系统提示您输入管理员密码或确认,请输入密码或提供确认。

3- Click Turn off Windows Firewall (not recommended) under each network location that you want to stop trying to protect, and then click OK. 3-单击要停止尝试保护的每个网络位置下的“关闭Windows防火墙(不推荐)”,然后单击“确定”。 Was this page helpful? 此页面是否有帮助?

Some times you need also 有时候你也需要

  1. To stop all Vpn client services (fortiClient ,vpn Client ...) 停止所有Vpn客户端服务(fortiClient,vpn客户端...)
  2. To stop Antivirus Firewall ( exemple Kaspersky => Configuration => Anti-Hacker) 停止防病毒防火墙(例如Kaspersky => Configuration => Anti-Hacker)

我正在使用jboss,因此解决您的问题的方法是重新启动。

service jboss-portal restart

I've encountered like this in Hybris. 我在Hybris中遇到过这种情况。

  1. Check your port in Resource Monitor > Network. 在资源监视器>网络中检查您的端口。 Check if other service is using your port. 检查其他服务是否正在使用您的端口。

1.2 If yes, then you need to change your properties in project.properties 1.2如果是,则需要在project.properties中更改属性

1.3 Change your address, any available address. 1.3更改您的地址,任何可用的地址。 In my case, I changed from 8000 to 8080. then save. 就我而言,我从8000更改为8080。然后保存。

java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8080,suspend=n yourServer
  1. In your console, rebuild your ant using command 'ant all' 在控制台中,使用命令“ ant all”重建您的ant

  2. Then debug again, using the command 'hybrisserver.bat debug' 然后使用命令“ hybrisserver.bat debug”再次调试

NOTE: For glassfish Server login via admin console -> Configurations -> server-config -> JVM-settings. 注意:对于glassfish服务器,请通过管理控制台->配置->服务器配置-> JVM设置登录。 * Remember to check Enable checkbox for Debug. *请记住选中“启用”复选框以进行调试。 Now Note the address, this address will be used in port of eclipse Remote Java Application Debug. 现在注意地址,该地址将在Eclipse Remote Java Application Debug的端口中使用。 Check the snap shot in glassfish server here 在此处检查glassfish服务器中的快照

I had and solved this problem by disconnecting from all remote Java applications in the debug window/perspective and restarting Eclipse. 我已经通过从调试窗口/透视图中的所有远程Java应用程序断开连接并重新启动Eclipse来解决了该问题。 I could connect again after doing so. 这样做后我可以再次连接。

卸载并再次安装ADT android插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 远程调试Eclipse:无法连接到远程VM - Remote Debugging Eclipse : Failed to connect to remote VM Eclipse在调试模式下启动Weblogic错误:“无法连接到远程VM” - Eclipse Start Weblogic in debug Mode error : “Failed to connect to remote VM” 连接远程虚拟机失败 - Failed to connect to remote VM Eclipse:本地调试(非远程)“无法连接到VM” - Eclipse: Local Debug (not remote) “Cannot connect to VM” eclipse:applet浏览器调试:无法连接到远程VM。 拒绝连接 - eclipse: applet browser debugging: failed to connect to remote VM. Connection refused 远程调试:无法连接到远程 VM。 连接超时 - Remote Debugging: Failed to connect to remote VM. Connection timed out 无法连接到Eclipse中的VM - Cannot connect to VM in Eclipse 连接远程虚拟机失败。 拒绝连接。 在glassfish上进行远程调试 - Failed to connect to remote VM. Connection refused. on glassfish for remote debugging Eclipse 在调试模式下启动时显示无法连接到 VM 错误 - Eclipse when launching in debug mode show Cannot connect to VM error 无法连接到远程VM。 拒绝连接。 尝试在Flash Builder 4.7中调试远程Java应用程序时 - Failed to connect to remote VM. Connection refused. when trying to debug remote java application in Flash Builder 4.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM