Skip to main content

Remote debugging in Netbeans

How to enable debuggning in netbeans on a remote server, to enable break points.

The server

Enable remote debugging in Tomcat.
Edit the service file

sudo nano /etc/systemd/system/tomcat[VERSION].service

Copy the "CATALINA_OPTS" line and comment the old one out

Add the following add the end of the line (before the ending ping)

 -XX:+UseParallelGC -Xdebug -Xrunjdwp:transport=dt_socket,address=*:9999,server=y,suspend=n

Save and exit nano

Reload the service

sudo systemctl daemon-reload

Restart tomcat

ts restart-webserver

Ensure that a process now is listening on port 9999

ss -lntu

Open port 9999 in the firewall using the IaaS providers interface

Netbeans

Ensure that you are running the same version of the software as the server, otherwise the break points wont make sense.

Attatch to the remote server

Select "Debug" and "Attach Debugger..."

image.png

Input the host and port 9999

image.png

Click OK

Find the "Debugger Console", normally in the bottom of the window, in the "Output" tab.

The console should read "User program running"

Try adding a break point and see if it works