Remote debugging of the Tomcat application with VSCode - NIAGADS/GenomicsDBWebsite GitHub Wiki

  1. Edit/create if does not exist: $CATALINA_HOME/bin/setenv.sh to add the following line:
# allow remote application debug
JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=<tomcat port>,server=y,suspend=n"

NOTE: <tomcat port> is the port on which your tomcat is running (default: 8080)

  1. In VSCode select Debug > Add Configuration from the menu; copy and paste the following in to the launch.json file that gets opened:
    {
        "type": "java",
        "name": "WDK-Tomcat",
        "request": "attach",
        "hostName": "localhost",
        "port": <tomcat port>,
        "projectName": "niagads-website-model"
    }

NOTE: <tomcat port> is the port you specified in your JPDA_OPTS

  1. Start the tomcat application in debug mode
sudo -u tomcat $CATALINA_HOME/bin/catalina.sh jpda start

NOTE: The sudo -u tomcat may be optional depending on how your system is configured

FYI: if you start with jdpa run instead of jdpa start tomcat will log in the current terminal window

  1. In VSCode, select Debug > Start Debugging from the menu

  2. To stop the tomcat application (after starting w/the catalina.sh use the following command:

sudo -u tomcat $CATALINA_HOME/bin/catalina.sh stop