TikiTavi
TikiTavi

Reputation: 252

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?

Upvotes: 5

Views: 13962

Answers (3)

Zlelik
Zlelik

Reputation: 578

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

Upvotes: 2

Martin Brown
Martin Brown

Reputation: 21

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"]

Upvotes: 2

Paul Tucker
Paul Tucker

Reputation: 141

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.

Upvotes: 6

Related Questions