问题
I have suddenly begun getting this weird error when I try to debug any of my projects on Eclipse. I don't remember changing anything for this problem to start so suddenly.
'Launching <my program name>' has encountered a problem.
Cannot connect to VM.
Details of the error:
Cannot connect to VM
com.sun.jdi.connect.TransportTimeoutException
Further, in the console I get the following error:
FATAL ERROR in native method: JDWP No transports initialized,
jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: transport error 202: connect failed: Connection timed out
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized
[../../../src/share/back/debugInit.c:750]
Please tell me how to solve this problem. I have searched the whole web for an answer but to no luck.
I tried the following solutions which worked for other people:
- Restarted Eclipse, restarted computer.
Change hosts file in etc\ - Remove the comments (#) sign before 2 lines namely,
127.0.0.1 localhost
::1 localhost
and restarted.
- Turned off all firewalls, restarted Eclipse and retried. Still no luck.
Somebody please help me, I'm going crazy.
Thanks
Sousa
回答1:
I just found this: Avast! 2014 I have it, and so it fits. If you do as well, then that is probably your problem.
回答2:
I am using Mac and I ran into similar issue. I made the changes to /etc/hosts file earlier, which I have reverted now to make it as below :-
127.0.0.1 localhost
And restarted the system and fixed my issue.
回答3:
After much stress and a lot of time, the problem is now resolved. Albeit in a very freaky way which does not amuse me as I can't figure out the rationale behind it. Anyways, here is what happened and maybe someone can throw some more light on what could have been the root cause of the problem.
I uninstalled Eclipse and Java completely from my system.
I then re-installed the latest version of Java (I had this same version previously too).
But this time I installed it in the standard directory and not the custom directory that I was using before (Probably something here was wrong the first time).
I then re-installed Eclipse (latest version again).
And just like that, it all started working normally again, Debug mode and everything!
What immediately comes to my mind is that the system environment variables could have got changed somehow. But I don't understand how this could have happened without me touching anything.
回答4:
I think the problem is because you have set the wrong path to jre .try right click on your project and click run configuration and set jre correct path. Could you please elaborate more about the issue.
回答5:
I ran into the same problem. It turned out that I have changed my /etc/hosts file where the ip address 127.0.1.1 was commented out. After uncommented it, it started to work again.
回答6:
Simply restart your PC,
it sounds silly but works most of the times.,
I don't have avast in my PC, but still ran into this problem.
Just restarted my PC and debug worked, I'm not sure what might be the problem exactly though.
回答7:
disable windows firewall and it's OK. TESTED.
回答8:
Sometimes when you try to debug your application, you will get the error like
Cannot connect to VM
com.sun.jdi.connect.TransportTimeoutException
FATAL:----------
ERROR:------------
ERROR:----------
WARN:-------------
I suggest you to turn-off your AVAST! FIREWALL and restart your system and then try debug your application. It will work fine.
Thanks Lokesh
回答9:
For me I had this issue when starting up the jetty-server and McAfee Antivirus Protection software was installed in my Windows 7 64 bit PC and as other mentioned I diabled the Firewall option and restarted eclipse workspace and started the server again. It worked!!!
Listening for transport dt_socket at address: 9000
I doubt there is a way to enable the port without disabling the firewall or maybe whitelist the specific port to be allowed by my antivirus softwares since this wont change often. Will post an update if I find one.
回答10:
I had a similar problem, when working with scrapbook. Fireval was in game mode. Then I turned off Fireval and scrapbook began to work.
回答11:
Same symptoms appeared quite suddenly after my setup had worked nocely for long time. The reason appeared one invalid line in my /etc/hosts file (I had added virtual NIC's ip there with translation to 'localhost'). Removing that line fixed it.
For someone with C background it is bit surprising that Eclipse reads /etc/hosts when you are debugging local Java application, but that appears to be the case.
回答12:
If you use a Windows OS, maybe this command can help you:
netsh winsock reset
回答13:
I got this: Unable to launch scrapbook VM com.sun.jdi.connect.TimoutException
I shut down Eclipse, disabled the Avast! firewall (as recommended but only for for 10 minutes), restarted Eclipse at which point I got a message from the Windows firewall about having blocked some Eclipse features. I checked the "public networks" checkbox (I'm on an employer provided network through wifi), restarted Eclipse and "voila", it is working again.
Windows Firewall Notification - Screen grab
回答14:
In my case, it was a matter of running Eclipse as Administrator. Once I did that, problem solved.
回答15:
In my case on a Mac, the "debug attach"
block in launch.json
was set to port 0.
I simply changed it to something else (8899), and it worked.
回答16:
My debugger was timing out before the test connected to the JRE.
I increased my java/debug 'debuggger timeout' setting and was able to run the test.
Reference:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=123118
来源:https://stackoverflow.com/questions/19633502/cannot-connect-to-vm-in-eclipse