To install the Java Agent on JBoss Standalone (Windows)

To install the Java Agent on JBoss Standalone:
  1. In the standalone.bat file, add the following javaagent argument.
    set JAVA_OPTS=%JAVA_OPTS% -javaagent:\agent_install_dir\javaagent.jar
  2. Specify the argument above the following section of standalone.sh:
    RESTART
    "%JAVA%" %JAVA_OPTS% ^
    "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
    "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
    -jar "%JBOSS_HOME%\jboss-modules.jar" ^
    -mp "%JBOSS_MODULEPATH%" ^
    -jaxpmodule "javax.xml.jaxp-provider" ^
    org.jboss.as.standalone ^
    "-Djboss.home.dir=%JBOSS_HOME%" ^
    %SERVER_OPTS%
  3. Restart the application server.
  4. Add the following to the end of the standalone.conf file in the JAVA_OPTS section:
    -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:{{}}
    <path_to_jboss_logmanager>\jboss-logmanager-<version>.jar
    For JDK9 and above, -Xbootclasspath/p option has been removed; use -Xbootclasspath/a instead:
    -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/a:
    <path_to_jboss_logmanager>/jboss-logmanager-<version>.jar
  5. Replace <path_to_jboss_logmanager> and <version> with the path and log manager JAR filename for your system.
    See Making the LogManager Location Dynamic for information on making the path dynamic.
    Note: Step 4 and Step 5 are required only if the log manager errors manifest. Also, repeat Step 3 after this change.
Dynamic LogManager Location

On standalone JBoss instances, instead of hard coding the path and name of the log manager JAR, you can use glob pattern matching techniques to make the path to the log manager file dynamic, so that it is resilient to change or variances among systems.

The exact steps to accomplish this varies by environment. These sections provide an example of this configuration on Windows and Linux systems, and are meant as a starting point for your own implementation.

Windows

In Windows, the standalone.conf.bat gets this additional snippet:

...
rem jboss.modules.system.pkgs
set JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman,com.singularity,org.jboss.logmanager
rem java.util.logging
set JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.manager=org.jboss.logmanager.LogManager
rem bootclasspath
set LOGMANAGER=
for /f %%i in ('dir /b "%JBOSS_HOME%\modules\system\layers\base\org\jboss\logmanager\main\jboss-logmanager-*.jar"') do (
set LOGMANAGER_JAR=%JBOSS_HOME%\modules\system\layers\base\org\jboss\logmanager\main\%%i
)
set JAVA_OPTS=%JAVA_OPTS% -Xbootclasspath/p:%LOGMANAGER_JAR%

The path to the LogManager JAR file under the JBoss home can vary by JBoss version. Be sure to check your system and adjust the path as shown in the example accordingly.

Linux

In Linux, you can populate the path dynamically with the following code:

JBOSS_MODULES_SYSTEM_PKGS ="org.jboss.byteman,com.singularity,org.jboss.logmanager"
JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$(ls ${JBOSS_HOME}/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-*.jar)"

If using the ${JBOSS_HOME} variable, as in the example, be sure to set the variable to the directory to the JBoss installation directory on your system.

The path to the LogManager JAR file under the JBoss home can vary by JBoss version. Be sure to check your system and adjust the path as shown in the example accordingly.