Remote debugging Tomcat with Eclipse

Viewed 288147

I can't seem to debug the tomcat application through Eclipse. I've set

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

and then I run bin/catalina.sh, where I see output saying it's listening for dt_socket on port 8000. But whenever I try to connect to port 8000 in Eclipse (by adding an entry in the remote java application menu), it complains about a refused connect. Any ideas?

16 Answers

Many of the above answers are correct, but remember that by default the debugger will listen on localhost, which means you can debug only if you're running the debugging client (for example, the IDE) on the same machine.

If you are debugging a remote server you will need to specify the correct IP address on that server to listen on, for example

JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=10.1.1.33:8000,server=y,suspend=n"

catalina.sh jpda start

Note that the address is now 10.1.1.33:8000

Of course, you can also check which IP is actually being used, by running

netstat -an

This command is valid on both windows and Linux - you just need to filter out the port with find (Windows) or grep (Linux).

If still all the above doen't work you can always add to the script

    set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

I was hitting this issue while running Tomcat inside of a Docker container. To fix this make sure you add the '-p 8000:8000' argument in your docker run command to expose this port to your local machine. You will of course need the setenv.sh file in your ${CATALINA_HOME}/bin/ within your container as well.

Related