Initialize the JVM
To install the Java Agent on JBoss EAP or JBoss Wildfly, you need to initialize the JVM. Run this parameter:
JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=org.jboss.byteman,com.singularity"
If you do not initialize the JVM, the installation generates a "class not found" exception.
Ensure that the property jboss.modules.system.pkgs
is available in the environment. If the property is present, then add com.singularity
to it.
For example:
-Djboss.modules.system.pkgs=org.jboss.byteman,com.singularity
If the property is not present, then configure a new one:
-Djboss.modules.system.pkgs=com.singularity
Standalone Mode Agent Installation
These instructions assume the use of Red Hat JBoss. For supported versions, see Application Servers.
To install the Java Agent on JBoss Standalone:- Linux
-
-
Open the
bin/standalone.sh
file. -
Add the following javaagent argument:
export JAVA_OPTS="$JAVA_OPTS -javaagent:/agent_install_dir/javaagent.jar"
-
Specify the argument above the following section of standalone.sh:
... while true;do if [ "x$LAUNCH_JBOSS_IN_BACKGROUND" = "X" ]; then # Execute the JVM in the foreground eval \"$JAVA\" -D\"[Standalone]\"$JAVA_OPTS \ \"-Dorg.jboss.boot.log.file=$JBOSS_LOG_DIR/boot.log\" \ \"-Dlogging.configuration=file:$JBOSS_CONFIG_DIR/logging.properties\" \ -jar \"$JBOSS_HOME/jboss-modules.jar\" \
-
Restart the application server.
-
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
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
-
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 5 and Step 6 are required only if the log manager errors manifest. Also, repeat Step 4 after this change.
-
- Windows
-
-
In the standalone.bat file, add the following javaagent argument.
set JAVA_OPTS=%JAVA_OPTS% -javaagent:\agent_install_dir\javaagent.jar
-
Specify the argument above the following section in standalone.bat:
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%
-
Restart the application server.
-
Add the following to the end of the standalone.conf.bat file in the
JAVA_OPTS
section.-Djava.util.logging.manager=org.jboss.logmanager.LogManager -Xbootclasspath/p:{{}} <path_to_jboss_logmanager>/jboss-logmanager-<version>.jar
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
-
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.