At one point, the remote debug used to work. But for the life of me, I don't seem to be able to figure out what broke it.
I have a flex/Java application. There is a wrapper that starts the tomcat server. I modified the wrapper.conf file to include
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
In my flex debug configurations, on the left, I have Remote Java Application. On the right, I have Standard (Socket Attach) as the connection type, 127.0.0.1 (I have tried localhost too) as Host, and 8000 as Port.
The following is the stack trace.
!ENTRY org.eclipse.jdt.launching 4 113 2013-09-03 11:30:49.109 !MESSAGE Failed to connect to remote VM. Connection refused. !STACK 0 java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at java.net.Socket.(Unknown Source) at java.net.Socket.(Unknown Source) at org.eclipse.jdi.internal.connect.SocketTransportService$2.run(SocketTransportService.java:136) at java.lang.Thread.run(Unknown Source)
Here is a screen shot of the debug configurations.
After much struggles, I finally got it figured out. I had to make two changes.
- I added tomcat.enable.debug=true to my catalina.properties file.
In my wrapper.conf, I had the following lines.
wrapper.java.additional.9="-Xmx2048m" wrapper.java.additional.10="-XX:MaxPermSize=1024m"
My MaxPermSize was set to a smaller size than Xmx. I had to change that 1024 to 2048.
I then restarted my tomcat and it worked, finally!
Each debug argument must be placed in a line by itself, after the -vm argument. This should do the trick:
-vmargs
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
Eclipse is not very verbose for this error "Connection refused". One has to check three entries here.
1. Fully qualified host name or IP
2. Correct port number.
3. At Tomcat level heck below:
Some versions of Tomcat has "dt_shmem" entry instead of "dt_socket". Change it to dt_socket in catalina.bat.
The line should looks like this:set JPDA_TRANSPORT=dt_socket
We must start Tomcat in remote mode rightly, otherwise just setting related variable cannot solve the problem. My solution is below and that works for my situation: Connection refused problem solution
If you validate Eclipse configuration settings and see that both hostname/IP and port name are correct, try to restart eclipse
来源:https://stackoverflow.com/questions/18599256/failed-to-connect-to-remote-vm-connection-refused-when-trying-to-debug-remote