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

Compatibility :3.5.46
Editions :Professional EditionStandard EditionCommunity Edition
Platforms :WindowsMac OSX (Not Supported)Linux (Not Supported)IBM AIX (Not Supported)FreeBSD (Not Supported)HP-UX (Not Supported)Solaris (Not Supported)IBM z/OS (Not Supported)IBM z/Linux (Not Supported)

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.

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.

NOTE

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

Compatibility :3.5.46
Editions :Professional EditionStandard EditionCommunity Edition
Platforms :WindowsMac OSXLinuxIBM AIXFreeBSDHP-UXSolarisIBM z/OSIBM 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.