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

3

4

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?

Economic answered 25/1, 2019 at 21:42 Comment(0)
T
5

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.

Transmontane answered 15/4, 2019 at 12:58 Comment(2)
Thanks for your answer @Paul Tucker. I've changed jobs and don't have the ability to test your solution, but it makes sense so I've accepted it.Economic
I believe the * syntax began with Tomcat9? If you're stuck debugging something older remotely, hopefully part of a migration effort, try address=0.0.0.0:$YourListingJdwpPortBookerbookie
D
2

I had similar issue running Tomcat 9 in docker. I specified the JPDA_ADDRESS in the docker build to allow access from any host:

ENV JPDA_ADDRESS=8000 CMD ["catalina.sh", "jpda", "run"]

Darbydarce answered 23/3, 2020 at 15:52 Comment(0)
C
2

In case you are on Windows and using Tomcat as Service 64-bit. Then it would be needed to change in the Windows registry. This registry path:

HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0\<Tomcat9ServiceName>\Parameters\Java

With 32-bit Windows this path will be without WOW6432Node. There is a string value Options and remote debug can be enabled by adding these 2 lines there

-Xdebug
-Xrunjdwp:transport=dt_socket,address=*:4446,server=y,suspend=n

if you do not put *: to address parameter, then remote debug will be possible only from localhost. *: means you can connect from anywhere/any host to the tomcat for debugging.

enter image description here

Tomcat9ServiceName - is the name of the Tomcat Service which shown in the screenshot below and usually you type it during the installation

enter image description here

Cogon answered 20/7, 2020 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.