Skip to content

Instantly share code, notes, and snippets.

@wwerner
Last active June 3, 2021 18:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wwerner/7a26e6b7408938f6a27b16e27cb316ac to your computer and use it in GitHub Desktop.
Save wwerner/7a26e6b7408938f6a27b16e27cb316ac to your computer and use it in GitHub Desktop.
Set up remote debugging for Tomcat in Docker

Set up remote debugging in dockerized Tomcat

Start Container, stock tomcat 8.5 in this example
$  docker run \
    -eJPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n" \
    -p8080:8080 \
    -p5005:5005 \
    tomcat:8.5-jdk8 \
    catalina.sh jpda run

In IntelliJ, add a launch configuration w/ the following properties:

  • Template: Remote

  • Debugger Mode: Attach to remote JVM

  • Host: localhost

  • Port: 5005

  • Commandline Arguments for remote JVM: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

Configuration in other debuggers/IDEs is basically the same.

Once the container is running, set a breakpoint / exception breakpoint & start the new launch configuration. The container now suspends once the breakpoint is hit & the stack is visible in your IDE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment