Problem:
When I try to run eclipse debugger, I am getting the error:
Failed to connect to remote VM. Connection refused
Solution:
- In the eclipse window, click on the debug icon, select "Remote Java Application" from the list of configurations.
Right click on the "Remote Java Application" and create a new configuration for your application.
On the right hand side, there will be three tabs, namely "Connect" ,"Source" and "Common".
Click on the "Connect" tab and set the connection properties, host as "localhost" and port as "8000". - In the environment variables, add an entry:
jpda_address=8000;
This is the default connection port used by eclipse when you try to connect to a remote VM for debug.
(When you don't have access to the environment variables, you can add
set jpda_address=8000
at the start of your startup.bat(inside the bin folder of tomcat).) - Open catalina.bat (inside the bin folder of tomcat) and search for "set JPDA_TRANSPORT".
Set the value to dt_socket. - Open startup.bat(inside the bin folder of tomcat) and search for
call "%EXECUTABLE%" start %CMD_LINE_ARGS%. (It's at the end of the file).
Replace this with:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
(mind the spaces, better copy and paste). - Save the changes and start the tomcat server using its startup.bat file.
The first line appearing on the server window should be "Listening for transport dt_socket at address: 8000". This indicates that all is well..
.
Go to eclipse debug perspective, add breakpoints and start debugging...
(source: forums.sun.com)
Labels:
