Installing Java Agent in Apache Tomcat
Installing Java Agent in Apache Tomcat in JIM Agent Installation & Configuration Guide.
Installing Java Agent in Apache Tomcat#
Unix Platform#
1. Navigate to the <path_to>/tomcat/bin/ path.
Open the catalina.sh or setenv.sh file. Add the following properties to the file.
2. Add JAVA_OPTS as follows:
a) If you have passed the otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
b) If you have commented out otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -Dotel.resource.attributes=service.name=<service identifier>,agent.uid=<agent identifier>,instance.uid=<instance identifier> -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
Note: All the parameters to the above command need to be in a single line. Do not press the 'Enter' key in between the parameters.
3. Adding permissions under catalina.policy
In the catalina.policy file for Apache Tomcat, add the following.
grant codeBase "file:/jim-agent/config/heal-jim-opentelemetry-javaagent-<version>.jar" {
permission java.security.AllPermission;
Add the below lines in the "grant" section.
permission java.io.FilePermission "<Tomcat_Home_Dir>/-", "read, write, delete";
permission java.io.FilePermission "<Jim-Agent-Dir>/-", "read, write";
Note: If you come across the error message below in jim logs:
Caused by: java.security.AccessControlException: Access denied ("java.lang.RuntimePermission" "getClassLoader")
Please refer to the Dealing with Java Security AccessControlException section in the Troubleshooting section.
4. Restart the Tomcat server.
Windows Platform#
1. Navigate to <path_to>\tomcat\bin\ path.
Create a setenv.bat file. Add the following properties to the file.
i. Add JAVA_OPTS as follows:
a) If you have passed the otel.resource.attributes in the agent-cache.properties file, enter the following argument.
set JAVA_OPTS=%JAVA_OPTS% -Dotel.javaagent.configuration-file=<JIM Agent path>\config\agent-cache.properties -javaagent: <JIM Agent path>\heal-jim-opentelemetry-javaagent-<version>.jar
b) If you have commented out otel.resource.attributes in the agent-cache.properties file, enter the following argument.
Set JAVA_OPTS=%JAVA_OPTS% -Dotel.javaagent.configuration-file=<JIM agent path>\config\agent-cache.properties -Dotel.resource.attributes=service.name=<service identifier>,agent.uid=<agent identifier>,instance.uid=<instance identifier> -javaagent:<JIM agent path>\heal-jim-opentelemetry-javaagent-<version>.jar"
Note: All the parameters to the above command need to be in a single line. Do not press the 'Enter' key in between the parameters.

2. The -javaagent argument must be specified before the application JAR file in the command line. This ensures the JVM processes the agent early in the startup sequence. If the Jim agent JAR is added after the application JAR, it may not initialize or load correctly.
3. Ensure no other instrumentation JAR files are added in the Java arguments. If any are present, consult with the application team and remove them before proceeding, as only one agent JAR should be used.
4. Restart the Tomcat server.
Installing Java Agent in JBoss#
1. Modify Java options in the start-up file to enable the JIM agent. To do so, append the following lines as a single line just below the existing JAVA_OPTIONS code in the standalone.sh file of the JBoss application server.
The standalone.sh file is available in the /jboss-eap-<version>/bin/ folder.
2. Add JAVA_OPTS as follows:
a) If you have passed the otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
b) If you have commented out otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -Dotel.resource.attributes=service.name=<service identifier>,agent.uid=<agent identifier>,instance.uid=<instance identifier> -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
Note: All the parameters to the above command need to be in a single line. Do not press the 'Enter' key in between the parameters.
3. Restart the JBoss server.
Installing Java Agent in Wildfly#
1. Modify Java options in the start-up file to enable the JIM agent. To do so, append the following lines as a single line just below the existing JAVA_OPTIONS code in the standalone.sh file of the Wildfly application server.
The standalone.sh file is available in <path>/wildfly-<version>.Final/bin/ folder.
2. Add JAVA_OPTS as follows:
a) If you have passed the otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
b) If you have commented out otel.resource.attributes in the agent-cache.properties file, enter the following argument.
JAVA_OPTS="$JAVA_OPTS -Dotel.javaagent.configuration-file=<JIM agent path>/config/agent-cache.properties -Dotel.resource.attributes=service.name=<service identifier>,agent.uid=<agent identifier>,instance.uid=<instance identifier> -javaagent:<JIM agent path>/heal-jim-opentelemetry-javaagent-<version>.jar"
Note: All the parameters to the above command need to be in a single line. Do not press the 'Enter' key in between the parameters.
3. Restart the Wildfly server.
Installation on Kubernetes#
Follow the steps below to install the JIM in a Kubernetes environment:
1. Before deploying the JIM agent, check the architecture of the nodes where the deployment will run:
uname -m
Supported architectures are the following:
- x86_64
- s390x
Note: The JIM Builds are architecture specific. Ensure to use the build with respect to your architecture.
2. Download and Load the JIM Agent Docker Image.
i. For Java version 8 and above:
For example:
For amd64 architecture, use the following image:
http://192.0.2.61:8081/nexus/repository/tls_docker_images/jim-agent-k8s-amd64_1.2.4.tar
* Execute the command below to load the Docker file:
docker load -i jim-agent-k8s-amd64_1.2.4.tar
Note: Replace <your-registry> with your actual container registry URL.
* Execute the command below to tag the image:
docker tag jim-agent-k8s-amd64:1.2.4 <your-registry>/jim-agent-k8s-amd64:1.2.4
* Execute the command below to push the Docker image to the container registry:
docker push <your-registry>/jim-agent-k8s-amd64:1.2.4
For example:
localhost:5000/healadmin/jim-agent-k8s-amd64:1.2.4
ii. For Java version 21:
Note: Separate JIM logging is not supported. All JIM logs will be included in the application pod logs.
For example:
For amd64 architecture, use the following image:
http://192.0.2.61:8081/nexus/repository/tls_docker_images/jim-agent-k8s-amd64_1.3.0.tar
* Execute the command below to load the docker file:
docker load -i jim-agent-k8s-amd64_1.3.0.tar
Note: Replace <your-registry> with your actual container registry URL.
* Execute the command below to tag the image:
docker tag jim-agent-k8s-amd64:1.2.4 <your-registry>/jim-agent-k8s-amd64:1.3.0
* Execute the command below to push the docker image to the container registry:
docker push <your-registry>/jim-agent-k8s-amd64:1.3.0
For example:
localhost:5000/healadmin/jim-agent-k8s-amd64:1.3.0
3. Ensure the jim-agent image is added under the init Containers section of your Kubernetes deployment or pod spec.
a. Ensure the volume mounts match your main container using the same agent-repo volume name.
For example:
i. Java 8 and above:
spec:
initContainers:
- name: jimagent
image: localhost:5000/healadmin/jim-agent-k8s-amd64:1.2.4
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /healagent
name: agent-repo
command: ["/bin/bash"]
args:
- "-c"
- "cp *.jar /healagent/ && mkdir -p /healagent/logs"
ii. Java 21:
spec:
initContainers:
- name: jimagent
image: localhost:5000/healadmin/jim-agent-k8s-amd64:1.3.0
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /healagent
name: agent-repo
command: ["/bin/bash"]
args:
- "-c"
- "cp -r /jim-agent_k8s/. /healagent/
4. Configure JAVA_TOOL_OPTIONS in Main Application Container: In your main application container, add the following environment variable to enable the JIM Java agent and point to the configuration file:
For example:
i. Java 8 and above:
containers:
- name: your-app-container
image: your-app-image
env:
- name: JAVA_TOOL_OPTIONS
value: >
-Dotel.javaagent.configuration-file=/healagent/agent-cache.properties
-javaagent:/healagent/heal-jim-opentelemetry-javaagent-1.2.4-SNAPSHOT.jar
volumeMounts:
- mountPath: /healagent
name: agent-repo
ii. Java 21:
containers:
- name: your-app-container
image: your-app-image
env:
- name: JAVA_TOOL_OPTIONS
value: >
-Dotel.javaagent.configuration-file=/healagent/agent-cache.properties
-javaagent:/healagent/heal-jim-opentelemetry-javaagent-1.3.0-SNAPSHOT.jar
volumeMounts:
- mountPath: /healagent
name: agent-repo
5. Ensure the agent-repo volume is consistently mounted in both the init container and the main container.
The below paths exist and are correct:
i. The agent-cache.properties directory:
/healagent/agent-cache.properties
The agent-cache.properties consist of the data as follows:
a. Java 8 and above:
* JIM Logging
jim.log.file.path=/healagent/
jim.log.pattern=[%-12date{YYYY-MM-dd HH:mm:ss.SSS}] [%logger{35}] [%level] - %msg%n
jim.log.file.max.size=1MB
jim.log.file.total.size.cap=5MB
jim.log.level=INFO
* Forensics:
heal.forensics.file.path=/healagent/
heal.forensics.keystore.file.path=/healagent/appnomic-keystore.jks
heal.forensics.keystore.password=<password>
heal.forensics.truststore.file.path=/healagent/appnomic-truststore.jks
heal.forensics.truststore.password=<password>
heal.forensics.http.connection.timeout.milliseconds=900000
heal.forensics.http.connection.socket.timeout.milliseconds=900000
heal.forensics.command.api=https://192.0.2.56:443/agent-command
heal.forensics.result.api=https://192.0.2.56:443/agent-forensics
heal.forensics.enable=true
heal.forensics.scheduler.interval.seconds=10
# Give multiple protocols name by comma separated
heal.forensics.ssl.supported.protocols=TLSv1.3
heal.forensics.command.api.instance.id.header.name=Instance-ID
heal.forensics.command.api.agent.id.header.name=Agent-ID
# Give application server name e.g tomcat or jboss or websphere or WebLogic
heal.forensics.application.server.name=tomcat
heal.forensics.buffer.size.kbs=16
b. Java 21:
java21: heal.forensics.file.path=/healagent/
heal.forensics.keystore.file.path=/healagent/appnomic-keystore.jks
heal.forensics.keystore.password=<password>
heal.forensics.truststore.file.path=/healagent/appnomic-truststore.jks
heal.forensics.truststore.password=<password>
heal.forensics.http.connection.timeout.milliseconds=900000
heal.forensics.http.connection.socket.timeout.milliseconds=900000
heal.forensics.command.api=https://192.0.2.56:443/agent-command
heal.forensics.result.api=https://192.0.2.56:443/agent-forensics
heal.forensics.enable=true
heal.forensics.scheduler.interval.seconds=10
# Give multiple protocols name by comma separated
heal.forensics.ssl.supported.protocols=TLSv1.3
heal.forensics.command.api.instance.id.header.name=Instance-ID
heal.forensics.command.api.agent.id.header.name=Agent-ID
# Give application server name e.g tomcat or jboss or websphere or weblogic
heal.forensics.application.server.name=tomcat
heal.forensics.buffer.size.kbs=16
ii. To update the other variables (if required) is as follows:
a. System attributes:
#-Dheal.forensics.file.path=/home/user/Downloads/ThreadDumpHealDump/dump
#-Dheal.forensics.keystore.file.path=/home/user/Downloads/ThreadDumpHealDump/appnomic-keystore.jks
#-Dheal.forensics.keystore.password=<password>
#-Dheal.forensics.truststore.file.path=/home/user/Downloads/ThreadDumpHealDump/appnomic-truststore.jks
#-Dheal.forensics.truststore.password=<password>
#-Dheal.forensics.http.connection.timeout.milliseconds=60000
#-Dheal.forensics.http.connection.socket.timeout.milliseconds=60000
#-Dheal.forensics.command.api=https://192.0.2.6:9998/agent-command
#-Dheal.forensics.result.api=https://192.0.2.6:9998/agent -forensics
#-Dheal.forensics.enable=false
#-Dheal.forensics.scheduler.interval.seconds=10
# Give multiple protocols name by comma separated
#-Dheal.forensics.ssl.supported.protocols=TLSv1.2,TLSv1.3
#-Dheal.forensics.command.api.instance.id.header.name=Instance-ID
#-Dheal.forensics.command.api.agent.id.header.name=Agent-ID
# Give application server name e.g Tomcat or Jboss or Websphere or Weblogic
#-Dheal.forensics.application.server.name=tomcat
#-Dheal.forensics.buffer.size.kbs=16
b. Environmental variables:
#HEAL_FORENSICS_FILE_PATH=/home/user/Downloads/ThreadDumpHealDump/dump
#HEAL_FORENSICS_KEYSTORE_FILE_PATH=/home/user/Downloads/ThreadDumpHealDump/appnomic-keystore.jks
#HEAL_FORENSICS_KEYSTORE_PASSWORD=<password>
#HEAL_FORENSICS_TRUSTSTORE_FILE_PATH=/home/user/Downloads/ThreadDumpHealDump/appnomic-truststore.jks
#HEAL_FORENSICS_TRUSTSTORE_PASSWORD=<password>
#HEAL_FORENSICS_HTTP_CONNECTION_TIMEOUT_MILLISECONDS=60000
#HEAL_FORENSICS_HTTP_CONNECTION_SOCKET_TIMEOUT_MILLISECONDS=60000
#HEAL_FORENSICS_COMMAND_API=https://192.0.2.6:9998/agent-command
#HEAL_FORENSICS_RESULT_API=https://192.0.2.6:9998/agent-forensics
#HEAL_FORENSICS_ENABLE=true
#HEAL_FORENSICS_SCHEDULER_INTERVAL_SECONDS=10
#HEAL_FORENSICS_SSL_SUPPORTED_PROTOCOLS=TLSv1.2,TLSv1.3
#HEAL_FORENSICS_COMMAND_API_INSTANCE_ID_HEADER_NAME=Instance-ID
#HEAL_FORENSICS_COMMAND_API_AGENT_ID_HEADER_NAME=Agent-ID
#HEAL_FORENSICS_APPLICATION_SERVER_NAME=tomcat
#HEAL_FORENSICS_BUFFER_SIZE_KBS=16
iii. The agent-cache.properties directory:
Note: If your application is Java-based and supports the -javaagent instrumentation flag.
a. Java 8 and above:
/healagent/heal-jim-opentelemetry-javaagent-1.2.4-SNAPSHOT.jar.
b. Java 21:
/healagent/heal-jim-opentelemetry-javaagent-1.3.0.jar.
6. Additional Volume Mounts for Configuration and Certificates
In your main application container, add the following under volume mounts:
For example: Below are the local YAML configurations:
volumeMounts:
- name: agent-cache-volume
mountPath: /healagent/agent-cache.properties
subPath: agent-cache.properties
- name: appnomic-keystore
mountPath: /healagent/appnomic-keystore.jks
subPath: appnomic-keystore.jks
readOnly: true
- name: appnomic-truststore
mountPath: /healagent/appnomic-truststore.jks
subPath: appnomic-truststore.jks
readOnly: true
7. Define required volumes in the pod spec by creating the required config map and secrets:
a. Create a config map for agent-cache.properties: You can create the Config Map either in your deployment YAML or directly from the CLI.
To create it from the CLI, execute the below commands:
kubectl create configmap <name of your config map> --from-file=/<path of your agent-cache.properties>/agent-cache.properties -n <name space of pod>
For example:
kubectl create configmap configmapjimforenisc --from-file=agent-cache.properties -n spring-petclinic-jim
Ensure you replace spring-petclinic-jim with your target namespace and path of agent-cache.properties.
b. Create secrets for the keystore and trust store.
i. These secrets are mandatory. They allow the JIM agent to securely connect to the Supervisor Controller (Heal side).
ii. These files are generated during Heal deployment.
iii. You can typically find them on the primary heal node under a directory below:
<installation directory>/Appsone_Service/data/cert
c. Required files:
i. appnomic-keystore.jks
ii. appnomic-truststore.jks
d. Ensure the following points:
i. To copy both files to a local path on the system from where you're running kubectl.
ii. The directory must be read-accessible.
e. Then create the Kubernetes secrets:
* Keystore:
kubectl create secret generic appnomic-keystore-secret --from-file=/<path of keystore>/appnomic-keystore.jks -n <name space of pod>
* Truststore:
kubectl create secret generic appnomic-truststore-secret --from-file=/<path of truststore>/appnomic-truststore.jks -n <name space of pod>
f. Replace the paths according to your environment.
i. agent-cache.properties: JIM configuration, required via ConfigMap.
ii. appnomic-keystore.jks and appnomic-truststore.jks: Required to connect the JIM agent with the Heal Supervisor, it must be stored as secrets.
g. Ensure these files are readable from the system you’re using for kubectl commands (as the container will need to read them at runtime to establish secure communication).
h. Once configmap and secret are created, follow the steps below.
Under the volumes section of your Kubernetes pod/deployment YAML, add the following:
volumes:
- name: agent-cache-volume
configMap:
name: configmapjimforenisc
items:
- key: agent-cache.properties
path: agent-cache.properties
defaultMode: 420
- name: appnomic-keystore
secret:
<password> appnomic-keystore-secret
defaultMode: 420
- name: appnomic-truststore
secret:
<password> appnomic-truststore-secret
defaultMode: 420
8. Restart the pod container.
9. Once it’s running, access the container using kubectl exec, navigate to the /healagent directory inside the pod and verify the JIM logs along with other file contents.