Class StopMojo

All Implemented Interfaces:
ContextEnabled, Mojo

@Mojo(name="stop", defaultPhase=POST_INTEGRATION_TEST, threadSafe=true) public class StopMojo extends AbstractTomcatMojo
Stops a running Apache Tomcat instance started by the start goal.

This goal attempts to stop Tomcat gracefully using the following strategy:

  1. If a PID file exists in CATALINA_BASE, terminates the process directly
  2. If no PID file is found, attempts to stop via the catalina script
  3. If graceful shutdown times out, forcibly terminates the process

Usage

mvn tomcat:stop

Configuration

The shutdown timeout can be configured using the tomcat.timeout.shutdown property (default: 30 seconds).

Since:
1.0.0
Author:
rajendarreddyj
See Also:
  • Constructor Details

    • StopMojo

      public StopMojo()
  • Method Details

    • execute

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

      This method performs the following steps:

      1. Builds the server configuration to locate CATALINA_BASE
      2. Checks for a PID file in CATALINA_BASE
      3. If PID file exists, terminates the process by PID
      4. If no PID file exists, attempts to stop via catalina script
      5. Cleans up the PID file after successful stop
      Throws:
      MojoExecutionException - if an error occurs during execution
      MojoFailureException - if execution fails due to invalid configuration