MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How to setup APM of Java Apps in AppDynamics?

To monitor a Java application in AppDynamics, you attach the AppDynamics Java Agent to the JVM with the -javaagent flag and point the agent at your Controller. You also need to send the application some traffic so the agent has transactions to report. This page fills in the steps above that were left empty: deploying a test app in Tomcat, downloading the agent, setting up the Controller connection, generating load with JMeter, and checking that data reaches the Controller.

Step 1 – Install Java

Step 2 – Install Tomcat

Step 3 – Run Apps in Tomcat

Step 4 – Download & Extract AppDynamics APM agent

Step 5 – Install the App Agent in Tomcat


$ vi /opt/apache-tomcat-9.0.63/bin/setenv.sh
	export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/appagent/javaagent.jar"
$ chmod 755 /opt/apache-tomcat-9.0.63/bin/setup.sh

$ ps -eaf | grep tomcat | grep javaagent.jar
root     24952     1 56 01:27 pts/1    00:00:02 /usr/bin/java -Djava.util.logging.config.file=/opt/apache-tomcat-9.0.63/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -javaagent:/opt/appagent/javaagent.jar -Dignore.endorsed.dirs= -classpath /opt/apache-tomcat-9.0.63/bin/bootstrap.jar:/opt/apache-tomcat-9.0.63/bin/tomcat-juli.jar -Dcatalina.base=/opt/apache-tomcat-9.0.63 -Dcatalina.home=/opt/apache-tomcat-9.0.63 -Djava.io.tmpdir=/opt/apache-tomcat-9.0.63/temp org.apache.catalina.startup.Bootstrap startCode language: JavaScript (javascript)

Step 6 – Install & Setup Jmeter

Step 7 – Create a Traffic at App using Jmeter & Visualize Data at AppDynmics


How the AppDynamics Java agent works

The AppDynamics Java Agent is a JAR file that loads into the JVM at startup through the standard -javaagent option. It instruments application bytecode to find business transactions, such as servlet requests, and to trace calls to databases, HTTP backends and message queues. It sends metrics and snapshots to the AppDynamics Controller, which can be a SaaS tenant or an on-premises installation. The Controller is where you see flow maps, response times and errors.

Every agent reports under three names that you choose: an application (the logical system), a tier (one service within it, for example web) and a node (one JVM instance). Choose these names before you start. They decide how your data is grouped in the Controller UI.

  • A Linux host with a supported JDK and Apache Tomcat installed (Steps 1 and 2 above).
  • Access to an AppDynamics Controller (a SaaS trial or on-premises), plus its hostname, port, SSL setting, account name and access key.
  • Outbound network access from the host to the Controller port, usually 443 for SaaS.
  • A non-root user that owns the Tomcat installation. The examples below use tomcat.

Deploy a test application in Tomcat

Step 3 above has no content. Any WAR file works. The quickest test target is the examples web application that ships with Tomcat. If you want your own app instead, copy its WAR file into webapps and Tomcat deploys it automatically.

# Use the bundled examples app
curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8080/examples/servlets/servlet/HelloWorldExample

# Or deploy your own WAR
cp myapp.war /opt/apache-tomcat-9.0.63/webapps/
tail -f /opt/apache-tomcat-9.0.63/logs/catalina.out   # wait for 'Deployment of web application archive ... has finished'Code language: PHP (php)

Note: An HTTP 200 means the app is reachable. Make sure the app works before you add the agent, so that any later failure can be traced to the agent setup.

Download and extract the Java agent

In the Controller UI, open the Getting Started wizard for Java. Alternatively, download the Java Agent for Sun and JRockit JVM (or the IBM JVM build, if you use an IBM JDK) from the AppDynamics downloads portal. The wizard is the easier route because it produces a ZIP with the Controller connection details already filled in. Extract it to a directory that the Tomcat user can write to. The agent writes its logs inside its own directory.

sudo mkdir -p /opt/appagent
sudo unzip AppServerAgent-*.zip -d /opt/appagent
sudo chown -R tomcat:tomcat /opt/appagent
ls /opt/appagent
# javaagent.jar  conf/  ver<version>/  ...Code language: HTML, XML (xml)

Connect the agent to your Controller

The original steps skip this, but without it the agent loads and has nowhere to send data. Edit /opt/appagent/conf/controller-info.xml and fill in your values. If the ZIP came from the Getting Started wizard, check the values that are already there.

<controller-info>
    <controller-host>mytenant.saas.appdynamics.com</controller-host>
    <controller-port>443</controller-port>
    <controller-ssl-enabled>true</controller-ssl-enabled>
    <account-name>mytenant</account-name>
    <account-access-key>YOUR_ACCESS_KEY</account-access-key>
    <application-name>DevOpsSchool-Demo</application-name>
    <tier-name>web</tier-name>
    <node-name>web-node-01</node-name>
</controller-info>Code language: HTML, XML (xml)

You can also pass the same settings as JVM system properties: -Dappdynamics.controller.hostName, -Dappdynamics.controller.port, -Dappdynamics.controller.ssl.enabled, -Dappdynamics.agent.accountName, -Dappdynamics.agent.accountAccessKey, -Dappdynamics.agent.applicationName, -Dappdynamics.agent.tierName and -Dappdynamics.agent.nodeName. System properties take precedence over the XML file. This is useful when several JVMs share one agent installation but each needs a different node name.

Note: For on-premises Controllers, the default port is usually 8090 for HTTP or 8181 for HTTPS. Use the values your Controller administrator gives you.

Corrected Tomcat setenv.sh configuration

The example above edits setenv.sh but then runs chmod on setup.sh, a file that does not exist. It also never restarts Tomcat, and the agent only loads when the JVM starts. Here is the corrected sequence:

cat > /opt/apache-tomcat-9.0.63/bin/setenv.sh <<'EOF'
#!/bin/sh
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/appagent/javaagent.jar"
# Optional: override the node name per JVM
# export CATALINA_OPTS="$CATALINA_OPTS -Dappdynamics.agent.nodeName=$(hostname)"
EOF
chmod 755 /opt/apache-tomcat-9.0.63/bin/setenv.sh

# Restart Tomcat so the JVM picks up the agent
/opt/apache-tomcat-9.0.63/bin/shutdown.sh
/opt/apache-tomcat-9.0.63/bin/startup.sh

# Verify
ps -ef | grep '[j]avaagent.jar'
grep -i 'AppDynamics' /opt/apache-tomcat-9.0.63/logs/catalina.out | tailCode language: PHP (php)

catalina.sh sources setenv.sh automatically when the file exists, so you never call setenv.sh yourself. Use CATALINA_OPTS rather than JAVA_OPTS. CATALINA_OPTS applies only to the Tomcat server process, while JAVA_OPTS also applies to shutdown.sh, which would load the agent a second time. In catalina.out you should see a line similar to Started AppDynamics Java Agent Successfully. On Windows, put the same option in bin\setenv.bat as set CATALINA_OPTS=%CATALINA_OPTS% -javaagent:C:\appagent\javaagent.jar.

Generate load with JMeter and view the data

The agent only reports business transactions that receive traffic. After you install JMeter (Step 6 above), create a test plan with a Thread Group and an HTTP Request sampler that targets your app. Run it in non-GUI mode, which uses fewer resources on the load generator:

# Run an existing test plan without the GUI
jmeter -n -t tomcat-load.jmx -l results.jtl -e -o report/

# Quick alternative without JMeter
for i in $(seq 1 500); do
  curl -s -o /dev/null http://localhost:8080/examples/servlets/servlet/HelloWorldExample
doneCode language: PHP (php)
  1. In the Controller, open Applications and select the application name you set, for example DevOpsSchool-Demo. The application can take a few minutes to appear after the first requests.
  2. On the Application Dashboard, check that the flow map shows the web tier and any backends it calls.
  3. Open Business Transactions to see the automatically detected servlet transactions, with calls per minute, average response time and errors.
  4. Open Tiers & Nodes to confirm that web-node-01 is reporting and to view JVM metrics such as heap and garbage collection.
  5. Use Transaction Snapshots to examine individual slow or failed requests down to the method level.

Troubleshooting common problems

SymptomLikely causeFix
javaagent.jar is missing from ps outputsetenv.sh was not sourced or Tomcat was not restartedCheck the file name and location (bin/setenv.sh), then do a full stop and start
Tomcat fails to start with Error opening zip file or JAR manifest missingWrong path to javaagent.jarCorrect the -javaagent path. Use an absolute path
Agent starts but the app never appears in the ControllerWrong host, port, SSL setting or access key, or a firewall blockCheck controller-info.xml and test the connection with curl -v https://<controller-host>:443
No agent logs, or permission errorsThe Tomcat user cannot write to the agent directoryRun chown -R tomcat:tomcat /opt/appagent
Node appears but no business transactionsNo traffic yet, or the URLs called are not instrumented entry pointsGenerate load against real servlet endpoints and wait a few minutes

Agent logs are in /opt/appagent/ver<version>/logs/<node-name>/. Look in agent.*.log for connection errors such as authentication failures or SSL handshake problems.

Best practices and security

  • Do not run Tomcat as root, as the sample ps output above does. Run it under a dedicated service account.
  • Treat the account access key as a secret. Restrict controller-info.xml to the Tomcat user (chmod 600), or inject the key from a secrets manager through an environment variable or system property.
  • Give each JVM a unique node name. Duplicate node names cause agents to overwrite each other's data.
  • Keep the agent version compatible with your Controller version, and test agent upgrades in a staging environment first.
  • Use one -javaagent APM agent per JVM. Running AppDynamics alongside another bytecode-instrumenting agent can cause conflicts. If you are evaluating vendor-neutral alternatives, see the OpenTelemetry end-to-end tutorial.

Frequently asked questions

Where do I add the AppDynamics javaagent option in Tomcat?

Add it to CATALINA_OPTS in $CATALINA_BASE/bin/setenv.sh on Linux, or in setenv.bat on Windows. If Tomcat runs as a systemd service that sets its own environment, add the option to the service's CATALINA_OPTS instead.

Do I need to restart Tomcat after installing the AppDynamics agent?

Yes. The -javaagent option is only read when the JVM starts, so Tomcat needs a full stop and start. A web application redeploy is not enough.

Why is my application not showing in the AppDynamics Controller?

Usually the connection details in controller-info.xml are wrong, outbound traffic to the Controller is blocked, or the app has not received any requests yet. Check the agent log under ver<version>/logs/<node-name>/ for the exact error.

Can one AppDynamics agent installation serve multiple JVMs?

Yes, several JVMs can point to the same javaagent.jar. Give each one a unique node name with -Dappdynamics.agent.nodeName, and make sure the agent directory is writable for log output.

Is JMeter required to see data in AppDynamics?

No. Any real or synthetic traffic works, including a simple curl loop. JMeter is useful because it produces steady, repeatable load that fills dashboards quickly.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals

Related Posts

Splunk Observability Cloud vs Splunk AppDynamics vs Splunk Cloud Platform

Hereโ€™s a clear and updated comparison between Splunk Observability Cloud, Splunk AppDynamics, and Splunk Cloud Platform, highlighting their purpose, strengths, and ideal use cases: ๐Ÿ“ฆ Product Overview…

Read More

Appdynamics: Dashboard and Dash Studio

In AppDynamics, both Dashboard and Dash Studio are used to visualize application performance and monitoring data, but they differ in features, flexibility, and intended use cases: 1….

Read More

Appdynamics: Lab – Create a Sample Load for APM in petclinic App using Jmeter

Hereโ€™s the exact JMeter setup to create Owners athttp://43.204.220.89:8080/petclinic/owners/new. Thread Group (your load) Config Elements Samplers & Post-Processors 1) GET form page (fetch cookies and optional CSRF)…

Read More

Appdyanmics: Correlate data across the App Agent, Machine Agent, and Database Agent

In AppDynamics, you correlate data across the App Agent, Machine Agent, and Database Agent by giving the Controller enough shared context to stitch them together. Hereโ€™s the…

Read More

Elastic: Elastic APM Java agent on Apache Tomcat

1) Prerequisites 2) Get your APM endpoint & token/key from Elastic Cloud 3) Download the Elastic APM Java Agent Create a directory for the agent and download…

Read More

AppDynamics Joins the Splunk Observability Portfolio

Based on the official information from Splunkโ€™s June 2026 update, hereโ€™s a crystal-clear breakdown of the current relationship and distinction between Splunk AppDynamics and the Splunk Observability…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x