Installing a Java™ virtualization agent into a Java™ application
To enable the Java™ virtualization agent to capture Java™ method calls being used by a Java™ application, you must load the agent into the application's Java™ virtual machine (JVM).
About this task
registration.xml
): greenhat.javaagent.jar
greenhat.javaagent.ext.jar
greenhat.javaagent.linkage.jar
The registration.xml
file
in JavaAgent package need not be in the same
directory as the JAR files, but by default, it is assumed that it
is. If you place the registration.xml
file in a different
location, specify the path in the javaagent property
in the following format: -javaagent:location of greenhat.javaagent.jar
file=location of registration.xml file
.
Procedure
-
Set the javaagent property in the
application environment in such a way that it points to the location
of the greenhat.javaagent.jar file.
The procedure of setting the property depends on the environment in use. The following sections outline steps for setting the property in a few commonly used environments. If you are using an environment that is not listed, see the relevant documentation to learn how to set the property.
- For a Standalone Java application, perform either of the following actions:
- Add the javaagent property to the command line that is used to launch the application. For example,
java -javaagent:C:\RITJavaVirtualizationAgent\greenhat.javaagent.jar sample.MyClass
- Before starting the Java application, set the JAVA_TOOLS_OPTIONS environment variable. For example,
JAVA_TOOL_OPTIONS="-javaagent:C:\RITJavaVirtualizationAgent\greenhat.javaagent.jar"
Note: When you set JAVA_TOOL_OPTIONS as a system environment variable, this option is used by all Java programs on your computer. This can affect application performance and can cause each Java program to register Java agents with Test Virtualization Control Panel.
- Add the javaagent property to the command line that is used to launch the application. For example,
- For WebSphere Application Server, perform the following actions:
- In the Websphere Integration Solution Console, click and select the server to be configured.
- Click .
- In the Generic JVM arguments field, add the following code:
-javaagent:C:\RITJavaVirtualizationAgent\greenhat.javaagent.jar
- For Apache Tomcat, perform the following actions:
- Go to Apache Tomcat installation directory/bin.
- Depending on your environment, open either the setenv.bat file or the setenv.sh file in a text editor.
- Edit the CATALINA_OPTS variable to include the javaagent property.The following example shows how the property is set in the setenv.bat file:
SET CATALINA_OPTS=%CATALINA_OPTS% -javaagent:"C:\RITJavaVirtualizationAgent\greenhat.javaagent.jar"
- For Redhat JBoss server, perform the following actions:
- Go to RedHat JBoss install directory/bin.
- Depending on your environment, open either the standalone.conf.bat file or the standalone.conf file in a text editor.
- Edit the JAVA_OPTS variable to include the javaagent property. The following example shows how the property is set in the standalone.conf.bat file:
SET JAVA_OPTS=%JAVA_OPTS% -javaagent:"C:\RITJavaVirtualizationAgent\greenhat.javaagent.jar"
- For a Standalone Java application, perform either of the following actions:
-
When you use the Java virtualization
agent with an application server such as IBM®
WebSphere® Application
Server that
has a Java 2 Security Manager, the agent might not run. In such cases,
the application server might fail to start unless you configure the
Security Manager correctly.
To configure a Java 2 Security Manager to work with the Java virtualization agent, add a permission of the following format to the server.policy file:
grant codeBase "file:C:/RITJavaVirtualizationAgent/*" { permission java.security.AllPermission; };
Note: If you use the WebSphere Application Server, the server.policy file is located in ${was.install.root}/profiles/${appserver.name}/properties. - Restart the application or the server for the changes to take effect.
Results
The application environment is configured to use the Java virtualization agent. Before you can capture any Java™ method calls in the Recording Studio perspective, you must create a Java™ method transport in HCL DevOps Test Integrations and APIs (Test Integrations and APIs). For information about how to create a Java™ method transport, see Creating logical Java application resources.