0

I am encountering the same error many times which has been discussed on Stack overflow before. For example here. My error says "Failed to connect to VM" when I right click on a java file, click on Debug As, selects Debug Configurations and then click on Debug button.One thing is different for me as compared to other people experiences mentioned in other posts on Stack overflow, I have noticed is that I only get this error when I try to follow the above steps on different java file after performing the same steps on some different file.

The quick fix I use every time is to shutdown the tomcat and then start again using catalina jpda start which is time consuming. I am wondering if there is any permanent fix available for this problem?

I am using Windows 10.

enter image description here

Community
  • 1
  • 1
Tan
  • 1,433
  • 5
  • 27
  • 47
  • Are you sure you're not reconnecting the debugger ? Because it happens in case debugger is already connected, it will show you an error saying it can not connect. To verify you can check in the Debug view. If you see the threads then it means you're already connected. If you just want to reconnect, just got to the top of threads and right click "terminate and relaunch" – 11thdimension Dec 29 '15 at 06:22
  • @11thdimension I think you are right, I am trying to reconnect on top of an already running instance. How should I cancel previous instance and connect again? When I right click on Daemon Thread, the `terminate and Relaunch` option is inactive. Please advise. Thanks – Tan Dec 29 '15 at 06:25
  • Can you post a screenshot of your Debug perspective ? – 11thdimension Dec 29 '15 at 06:28
  • @11thdimension Added. I have removed some stuff which is not relevant. I was referring to the daemon Thread on the top left section. – Tan Dec 29 '15 at 06:34
  • Ok, Daemon thread is just a single thread, you'll have to go to the root of the Threads, there you'll be able to see the option for terminating and relaunching. I'll post a screenshot in an answer if it's not clear yet. – 11thdimension Dec 29 '15 at 06:36
  • Thanks, I got it. So, for every remote java application, I will have to terminate the previous top thread and run new again, right? – Tan Dec 29 '15 at 06:41
  • Yes, however if your connection is already established then there's no good reason to relaunch it. Unless you have modified code and deployed new class files. – 11thdimension Dec 29 '15 at 06:50

1 Answers1

1

As I commented, you're probably trying to connect a debugger when it's already connected. If you want to relaunch it you can do it by right clicking on your application JVM in Debug Perspective.

See the image below

enter image description here

Thread [main] is just one thread, your application may contain hundreds of threads, which will all be under application name.

In the image above application is FindMultiGenes5. In your case it should be the name of debug configuration your provided.

See the image below

enter image description here

According to above image I would expect my application threads to appear under TestProject_debug name in debug perspective.

11thdimension
  • 10,333
  • 4
  • 33
  • 71