0

I'm trying to remote debug a Tomcat. I added -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 to JAVA_OPTS and restarted Tomcat. IntelliJ wasn't able to attach. So I tried telnet thehost 5005 and it seemed I was initially attached but then my session was terminated with Connection closed by foreign host and catalina.out had Debugger failed to attach: timeout during handshake. Same thing happened if I did telnet localhost 5005 on the remote machine.

If I do netstat -antp | grep 5005 on the remote machine I get

tcp 0 0 0.0.0.0:5005 0.0.0.0:* LISTEN 26745/java-tomcat12

So it seems the JVM is listening. What am I doing wrong?

Update: using the same options I can debug a very simple hello world like application which I run on the remote server. So it seems it's something specific to Tomcat, or at least this specific web application.

Johnny
  • 7,073
  • 9
  • 46
  • 72
  • Have you tried with `-Xdebug` ? [See here](https://stackoverflow.com/a/36420167/5810894) – pan Mar 31 '20 at 12:01
  • It's java 8, `-Xdebug` is for earlier versions I believe. – Johnny Mar 31 '20 at 12:15
  • Oh, my bad. You are correct! – pan Mar 31 '20 at 12:23
  • 1
    Not sure why but the debugger only allows attaching from the same host, so I had to create a SSH tunnel from my computer to the remote host. BTW, I mistakenly thought that telnet connecting and then terminating the session was a bad sign but it just meant that the JVM is listening and all is good. – Johnny Apr 01 '20 at 06:52

0 Answers0