Connecting to a Java process in Tomcat for debugging
Answered
I'm getting an error, "Unable to open debugger port (localhost: 8000): java.io.IOException - connection prematurally closed"
I've checked to make sure the Java process, running in Tomcat with a Docker container has port 8000 exposed. I'm using Java 8, and matched the setup for another service that I WAS able to connect to for debugging, yet this one doesn't work... and "prematurally" isn't spelled correctly, btw.
Please sign in to leave a comment.
What run/debug configuration do you use? Can you telnet to this host/port from the machine where IntelliJ IDEA is running?
It's running locally, and telnet doesn't seem to understand "localhost:8000" so I'm not sure about that part.
I have, AFAIK, set the Java process to expose port 8000 for debugging, and I set up a remote run configuration to connect to the local port 8000. I got this working for one microservice, but not the 2nd, even though AFAIK I've matched settings.
Telnet works with space instead of the colon. `telnet localhost 8000`.
Verify the debug options were picked up by the process. Check that debugger port doesn't conflict with other ports (like HTTP port) and with other apps. Still not clear what type of the run/debug you are using and what are your settings for the debugger and what parameters are used to start the process you are trying to debug.
JDK params:
(I added the last line while troubleshooting.)
The command line includes:
As far as debug params, I created a new debug config, and used the default settings except for the port, which I set to 8000.
IntelliJ IDEA has a dozen of run/debug configurations (Application, Remote, Tomcat Local/Remote, Docker, etc), it's not clear what you mean by the "default debug config".
Can you telnet to port 8000?
The last line is incorrect, it must have a dash before agentlib (-agentlib).
Tomcat must be started with `jpda run` command line arguments to enable debugging.
See https://www.dontpanicblog.co.uk/2017/03/12/tomcat-debugging-in-docker/.