All Articles

How to start tomcat debug mode

Tomcat 9 debug mode

Technical stack

  • Maven
  • JDK 17
  • Docker Desktop or Rancher Desktop
  • Start tomcat with address: http://localhost:8080
  • Debug port default: 8000

Configuration

Standalone Tomcat server

  • Add user with role mageger-gui to deploy war file from GUI,

edit [tomcat-9]\conf\tomcat-users.xml

<user username="admin" password="admin" roles="manager-gui"/>
<role rolename="manager-gui"/>
  • I need to set JAVA_HOME JDK 17 for tomcat 9 because my environment got java 1.8, 11, 17.

Add at first line [tomcat-9]\bin\catalina.bat

set "JAVA_HOME=D:\work\javatools\jdk-17.0.10"

Add JPDA_ADDRESS in case you want to change debug port, otherwise JPDA_ADDRESS=8000 is default. Change default debug port tomcat, override JPDA_ADDRESS.

  • Start tomcat with console
[tomcat]\bin\catalina.bat jpda run

Docker

  • Dockerfile
FROM tomcat:9.0-jdk17
COPY target/example-soap.war /usr/local/tomcat/webapps/
EXPOSE 8080 8000
  • docker-compose.yml
version: '3.9'
services:
  example-soap:
    build:
      context: '.'
    command: bash -c "catalina.sh jpda run"
    environment:
        JPDA_ADDRESS: "*:8000"
    ports:
      - "8080:8080"
      - "8000:8000"
  • Start docker compose

Remember build codes before start

docker-compose build --up

Published Oct 5, 2024

I blog about web development and my travels