Overview

On some installations, the wrapper.java.command property may point to a script or an executable that will redirect to a different process, the one actually running your application. This is the case, for example, when the Java command points to C:\Program Files\Common Files\Oracle\Java\javapath\java.exe (often because Oracle Java configures the PATH environment variable with this entry during installation). Depending on how signals are forwarded to the Java process, this redirect may cause certain features such as thread dump requests to not work correctly.

To detect when this is happening, the Wrapper will compare the PID of the Java process just after it started and the PID of the proccess that it launched. If they differ, a warning will be printed.

On Windows, the Wrapper will automatically switch to monitoring the Java process instead of the process launched to ensure a proper functionning. If the Java PID file is used, the file will be updated with the new PID.

The output should look like this:

STATUS | ----- | wrapper  | Launching a JVM...
INFO   | 16960 | jvm 1    | WrapperManager: Initializing...
INFO   | 16960 | jvm 1    | TestWrapper: Initializing...
WARN   | 16960 | wrapper  | Detected that the Java process launched by the Wrapper (PID 16960) was redirected to C:\Program Files\Java\jdk-16.0.1\bin\java.exe (PID 1148).
WARN   | 16960 | wrapper  |  Switch to monitoring the Java process.
INFO   |  1148 | jvm 1    | TestWrapper: start()
INFO   |  1148 | jvm 1    | TestWrapper: ActionServer Enabled.
INFO   |  1148 | jvm 1    | TestWrapper:   Telnet localhost 9999
INFO   |  1148 | jvm 1    | TestWrapper:   Commands:
INFO   |  1148 | jvm 1    | TestWrapper:     S: Shutdown
INFO   |  1148 | jvm 1    | TestWrapper:     H: Expected Halt
INFO   |  1148 | jvm 1    | TestWrapper:     R: Restart
INFO   |  1148 | jvm 1    | TestWrapper:     D: Thread Dump
INFO   |  1148 | jvm 1    | TestWrapper:     U: Unexpected Halt (Simulate crash)
INFO   |  1148 | jvm 1    | TestWrapper:     V: Access Violation (Actual crash)
INFO   |  1148 | jvm 1    | TestWrapper:     G: Make the JVM appear to be hung.

This behavior can be configured with the following properties:

wrapper.java.monitor

Compatibilidad :3.5.46
Ediciones :Edición ProfesionaEdición EstándarEdición de la Comunidad
Plataformas :WindowsMac OSX (No Compatible)Linux (No Compatible)Alpine Linux (No Compatible)IBM AIX (No Compatible)FreeBSD (No Compatible)Solaris (No Compatible)IBM z/Linux (No Compatible)

This property is used on Windows to tell the Wrapper whether it should keep monitoring the process that it launched or automatically switch to the Java process in case a redirect occurred. On UNIX systems the Wrapper will always monitor the process that it launched.

The default value is JAVA which makes the Wrapper always try to monitor the Java process running your application.

The value 'LAUNCHED' can be used to keep monitoring the process launched by the Wrapper like it was with versions of the Wrapper prior to 3.5.46.

NOTA

Since version 3.7.0, the Wrapper has implemented stricter verification regarding process redirection:

Previously, when using LAUNCHED mode, the Wrapper would continue to monitor the Java process life cycle via the backend connection even if a redirection occurred. While the core monitoring stayed functional, certain features (such as thread dump requests and signal handling) were disabled because they specifically require a PID match. This was the standard behavior on both Windows and UNIX.

Version 3.7.0 introduces several improvements to strengthen the authentication of the Java process connecting to the Wrapper. One of them is to verify that the PID reported by Java is legitimate.

To best work with PID verification and offer the most secure authentication, the LAUNCHED mode has been made strict, enforcing PID stability. This allows the Wrapper to verify that the connecting process is exactly the one it launched, rejecting the incoming connection otherwise.

A LEGACY mode has been added to maintain backward compatibility, though it is neither required nor recommended for most scenarios.

Note that redirection is still permitted when using JAVA mode (available only on Windows). Even in this mode, the Wrapper continues to look up the PID within its process hierarchy and verify that it corresponds to the peer process. This provides a less stringent authentication than under LAUNCHED mode, but remains the default on Windows to maintain compatibility with the default Oracle Java installer, which uses a 'javapath' redirector to launch the JVM.

For environments with high-security requirements, it is recommended to use LAUNCHED mode and ensure that wrapper.java.command (or JAVA_HOME) points directly to the actual Java executable rather than a redirector.

Example: (Keep monitoring the process launched by the Wrapper)
wrapper.java.monitor=LAUNCHED

The output should look like this:

STATUS | ----- | wrapper  | Launching a JVM...
INFO   | 16960 | jvm 1    | WrapperManager: Initializing...
INFO   | 16960 | jvm 1    | TestWrapper: Initializing...
WARN   | 16960 | wrapper  | Detected that the Java process launched by the Wrapper (PID 16960) was redirected to C:\Program Files\Java\jdk-16.0.1\bin\java.exe (PID 1148).
WARN   | 16960 | wrapper  |  Switch to monitoring the Java process.
INFO   |  1148 | jvm 1    | TestWrapper: start()
INFO   |  1148 | jvm 1    | TestWrapper: ActionServer Enabled.
INFO   |  1148 | jvm 1    | TestWrapper:   Telnet localhost 9999
INFO   |  1148 | jvm 1    | TestWrapper:   Commands:
INFO   |  1148 | jvm 1    | TestWrapper:     S: Shutdown
INFO   |  1148 | jvm 1    | TestWrapper:     H: Expected Halt
INFO   |  1148 | jvm 1    | TestWrapper:     R: Restart
INFO   |  1148 | jvm 1    | TestWrapper:     D: Thread Dump
INFO   |  1148 | jvm 1    | TestWrapper:     U: Unexpected Halt (Simulate crash)
INFO   |  1148 | jvm 1    | TestWrapper:     V: Access Violation (Actual crash)
INFO   |  1148 | jvm 1    | TestWrapper:     G: Make the JVM appear to be hung.

NOTA

Some Java installations on UNIX are set up with a Shell Script to help switching JVMs. Generally the PID between the Shell Script and the Java process is unchanged because the later is launched with 'exec'. If you plan to write your own script to launch Java, it is recommended to also use the exec command when calling Java. The Wrapper will show a warning if it detects the PID changed, but won't change the monitored process.

wrapper.java.monitor.redirect.loglevel

Compatibilidad :3.5.46
Ediciones :Edición ProfesionaEdición EstándarEdición de la Comunidad
Plataformas :WindowsMac OSXLinuxAlpine LinuxIBM AIXFreeBSDSolarisIBM z/Linux

In some cases, it is known that the behavior to either switch to monitoring the Java process or keep monitoring the launched process is not going to cause any undesired effects. The wrapper.java.monitor.redirect.loglevel property lets you control the log level of messages that the Wrapper prints when it detects that the Java process differs from the process that it launched, and can be turned to DEBUG to skip warnings during normal executions.

The default value is WARN.

Example: (Only show message in debug mode)
wrapper.java.monitor.redirect.loglevel=DEBUG

The output should look like this:

STATUS | ----- | wrapper  | Launching a JVM...
INFO   | 16960 | jvm 1    | WrapperManager: Initializing...
INFO   | 16960 | jvm 1    | TestWrapper: Initializing...
INFO   |  1148 | jvm 1    | TestWrapper: start()
INFO   |  1148 | jvm 1    | TestWrapper: ActionServer Enabled.
INFO   |  1148 | jvm 1    | TestWrapper:   Telnet localhost 9999
INFO   |  1148 | jvm 1    | TestWrapper:   Commands:
INFO   |  1148 | jvm 1    | TestWrapper:     S: Shutdown
INFO   |  1148 | jvm 1    | TestWrapper:     H: Expected Halt
INFO   |  1148 | jvm 1    | TestWrapper:     R: Restart
INFO   |  1148 | jvm 1    | TestWrapper:     D: Thread Dump
INFO   |  1148 | jvm 1    | TestWrapper:     U: Unexpected Halt (Simulate crash)
INFO   |  1148 | jvm 1    | TestWrapper:     V: Access Violation (Actual crash)
INFO   |  1148 | jvm 1    | TestWrapper:     G: Make the JVM appear to be hung.