Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/site/apt/usage.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,43 @@ mvn exec:exec -Dexec.executable="maven" [-Dexec.workingdir="/tmp"] -Dexec.args="
*--------------------------------------+------------------------------------------+
| The VM exits as soon as the only | By default daemon threads are joined |
| remaining threads are daemon threads | and interrupted once all known non |
| | daemon threads have quit. The join |
| | timeout is customisable |
| | The user might wish to further |
| | daemon threads have quit. The join |
| | timeout is customisable. |
| | The user might wish to further |
| | cleanup by stopping the unresponsive |
| | threads. |
| | The user can disable the full extra |
| | thread management (interrupt/join/[stop])|
*--------------------------------------+------------------------------------------+

*** Important limitation: Thread Group Isolation

The java goal tracks threads created within its own <<isolated thread group>>.
It does <<not>> track threads created in other thread groups.
This means that if your code creates threads outside the isolated thread group
(for example, through RMI, JMX, or other frameworks), those threads will not be
detected as "known" threads, and the plugin may exit even if such non-daemon threads are still running.

<<Examples of affected scenarios:>>

* <<RMI>> - <<<java.rmi.registry.LocateRegistry.createRegistry()>>> creates non-daemon threads
in the system thread group, not in the plugin's isolated thread group.

* <<JMX>> - Similar to RMI, JMX remote connectors may create threads outside the isolated group.

* <<Other frameworks>> that manage their own thread pools or create threads using
the system thread group.

[]

In such cases, the plugin will exit when all threads in <<its own thread group>> have completed,
even though non-daemon threads may still be running in other thread groups. This can cause
servers or services to be terminated prematurely.

<<Workaround:>> If you need threads created by frameworks like RMI to keep the JVM alive,
use the {{{./exec-mojo.html}exec goal}} to run your Java program in a separate JVM process instead.
The exec goal spawns a new process which will behave like running <<<java>>> from the command line.

Read the documentation for the {{{./java-mojo.html}java goal}} for more information on how to configure this behavior.

If you find out that these differences are unacceptable for your case, you may need to use the {{{./exec-mojo.html} exec goal}} to wrap your Java executable.
Expand Down