Clone this repository as a new IntelliJ IDEA project and try running and debugging a Java Enterprise web application using Docker Compose and remote debug.
- Build the WAR artifact: Build -> Build Artifacts
- Open
docker-compose.yaml
and click the icon with green arrows in the gutter to run it via Docker Compose. - Wait for the Tomcat container to start (the container log show say "Server startup in [xxxxx] milliseconds").
- Open this URL, which should return
Hello, World!
http://localhost:8888/Tomcat_docker_debug-1.0-SNAPSHOT/api/hello-world - Run the
remote_tomcat_debug
configuration to attach the debugger. - Set a breakpoint, for example, on the REST method
hello()
, where it returns "Hello, World!" - Refresh or open the URL again http://localhost:8888/Tomcat_docker_debug-1.0-SNAPSHOT/api/hello-world
Result: it should stop at the breakpoint.
You can add the Docker Compose run configuration as a Before launch task in the
remote_tomcat_debug
configuration. However, there is currently an issue with this that the remote debug configuration starts before the Docker Compose has time to start the service. This issue will be fixed in 2023.3.
This tutorial uses Tomcat 10.0 with Jakarta EE 9.1. You can choose a different combination:
- Tomcat 10.1 + Jakarta EE 10
- Tomcat 9 and earlier + Java EE 8