Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java remote debugging (JPDA) not working for me in Tomcat 9

I'm trying to remotely debug a Tomcat webapp on a recently upgraded Tomcat 9.0.13 and Open JDK 11.0.1. Server is Redhat Enterprise Linux 7.6 and I'm using Eclipse on a Windows 7 developer box to connect.

Tomcat starts, and the app is accessible on port 8080 but fails on certain requests. So on my Eclipse, I've configured a Remote Java application with my configuration details. When I try to connect to it, the connecting fails with

Failed to connect to remote VM. Connection refused.

I'm using the default port, 8000 and on the Linux server, netstat -an shows that there is a process listening on that port when Tomcat starts and not when Tomcat stops.

I've tried telnet from the Windows box to port 8000 and get

$ telnet c516vefpubrec 8000
Trying XX.XXX.XX.XX...
telnet: Unable to connect to remote host: Connection refused

When I do the same running our old Tomcat 7 + Java 1.8 everything is successful. I've tried other ports with the same result.

Could this be a bug? Is there a configuration item to enable JPDA on Tomcat 9?

like image 271
TikiTavi Avatar asked Jan 02 '23 09:01

TikiTavi


1 Answers

I had this exact same issue. I'm running an application from a centos vm and trying to debug from my windows machine.

I had to go into the catalina.sh file on the vm and make an edit. In the section that says that handles the jpda flag, the JPA_OPTS variable needed to be changed to JPDA_OPTS="-agentlib:jdwp=transport=$JPDA_TRANSPORT,address=*:$JPDA_ADDRESS,server=y,suspend=$JPDA_SUSPEND"

Note the *: before the JPDA variable. This allows any ip address to have access to remote debugging. I believe by default it only allows local host.

Hope this helps.

like image 109
Paul Tucker Avatar answered Jan 13 '23 18:01

Paul Tucker