Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding -javaagent to Tomcat 6 server, where do I put it and in what format?

I´m trying to install an application health monitoring application that can monitor J2EE web transactions and I need to put a javaagent into my Tomcat somehow but am not clear on exactly how to do this, I am using Linux and have been instructed by the software company that makes this product to do something like below:

-javaagent:<Path to the WebTransactionAgent.jar>

I have received further support from them and they basically said to put this into the appropriate .sh file (but they weren´t able to tell me which file that is for Tomcat)

I tried putting this in the catalina.sh file but it does not seem to be working:

JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=256m -javaagent:"C:\WebTransactionAgent.jar"

Any advice is appreciated

like image 851
Rick Avatar asked Jul 14 '11 16:07

Rick


People also ask

Where do I put Tomcat files?

By default, these files are located at TOMCAT-HOME/conf/server. xml and TOMCAT-HOME/conf/web. xml, respectively.

How do I connect to a local Tomcat server?

Access the Apache Tomcat console by browsing to http://localhost:8080/ (if installed as a non-root user) or http://localhost/ (if installed as the root user).

What is Tomcat folder structure?

The typical directory hierarchy of a Tomcat installation consists of the following: bin - startup, shutdown and other scripts and executables. common - common classes that Catalina and web applications can use. conf - XML files and related DTDs to configure Tomcat. logs - Catalina and application logs.


2 Answers

For Unix/Linux, do this in <tomcat_home>/bin/setenv.sh, e.g.

CATALINA_OPTS="$CATALINA_OPTS -javaagent:/path/to/YourJar.jar"

You might need to create this file if not present and chmod it to 711 or 755.

For Windows, the counterpart is setenv.bat.

like image 200
mindas Avatar answered Oct 13 '22 05:10

mindas


To add to mindas' answer, the -javaagent command could also be added to the JAVA_OPTS environment variable in one of the following (if they exist):

<tomcat_home>/conf/tomcat6.conf

JAVA_OPTS="${JAVA_OPTS} -javaagent:/full/path/to/YourJar.jar"

or <tomcat_home>/bin/catalina.sh

export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/YourJar.jar"
like image 29
brasskazoo Avatar answered Oct 13 '22 06:10

brasskazoo