Class DebugMojo

All Implemented Interfaces:
ContextEnabled, Mojo

@Mojo(name="debug", defaultPhase=PRE_INTEGRATION_TEST, requiresDependencyResolution=RUNTIME, threadSafe=true) public class DebugMojo extends AbstractTomcatMojo
Runs Apache Tomcat in debug mode with JDWP agent enabled.

This goal starts Tomcat with Java debugging enabled, allowing IDEs (VS Code, IntelliJ, Eclipse) to attach and debug the running application. The goal blocks until the process is terminated (Ctrl+C).

Usage

mvn tomcat:debug

IDE Connection

Connect your IDE debugger to localhost:{debugPort} (default: 5005)

VS Code

Add to launch.json:


 {
 "type": "java",
 "name": "Attach to Tomcat",
 "request": "attach",
 "hostName": "localhost",
 "port": 5005
 }
 

IntelliJ IDEA

Run → Edit Configurations → Add → Remote JVM Debug → Port: 5005

Eclipse

Run → Debug Configurations → Remote Java Application → Port: 5005

Configuration Example


 <plugin>
 <groupId>io.github.rajendarreddyj</groupId>
 <artifactId>tomcat-maven-plugin</artifactId>
 <configuration>
 <httpPort>8080</httpPort>
 <debugPort>5005</debugPort>
 <debugSuspend>false</debugSuspend>
 <contextPath>/myapp</contextPath>
 </configuration>
 </plugin>
 
Since:
1.0.0
Author:
rajendarreddyj
See Also:
  • Constructor Details

    • DebugMojo

      public DebugMojo()
  • Method Details

    • execute

      public void execute() throws MojoExecutionException, MojoFailureException
      Executes the debug goal.

      This method performs the following steps:

      1. Validates Java version compatibility with the configured Tomcat version
      2. Validates that the HTTP port is available
      3. Validates that the debug port is available
      4. Builds server configuration with JDWP debug options
      5. Deploys the webapp to Tomcat's webapps directory
      6. Starts the hot deploy watcher if auto-publish is enabled
      7. Prints debug connection instructions
      8. Starts Tomcat in foreground mode and blocks until shutdown
      Throws:
      MojoExecutionException - if an error occurs during execution
      MojoFailureException - if execution fails due to invalid configuration