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

3

11

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

Cavalier answered 14/7, 2011 at 16:55 Comment(0)
C
16

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.

Curvilinear answered 14/7, 2011 at 16:58 Comment(3)
thanks, just a note, however you mis-spelled javaagent above so if anyone is copying and pasting this may throw them offCavalier
i need to add aspectj Loadviewer jar in tomcat7 catalina.bat file i place at the first line but it wont work. set JAVA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jar and i tried with this also set CATALINA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jarIodic
Alternatively, You might also find CATALINA_OPTS in your <tomcat_home>/bin/startup.shBakerman
F
3

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"
Foudroyant answered 15/2, 2013 at 1:29 Comment(1)
i need to add aspectj Loadviewer jar in tomcat7 catalina.bat file i place at the first line but it wont work. set JAVA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jar and i tried with this also set CATALINA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jarIodic
G
0

Use JAVA_OPTS as CATALINA_OPTS would not allow JVM options [option2]=[value2].

Example, for adding jacocoagent.jar with options as below, only JAVA_OPTS will work.

JAVA_OPTS="${JAVA_OPTS} -javaagent:$CATALINA_HOME/lib/jacocoagent.jar=destfile=/tmp/jacoco.exec"
Gannie answered 5/5, 2014 at 9:21 Comment(1)
i need to add aspectj Loadviewer jar in tomcat7 catalina.bat file i place at the first line but it wont work. set JAVA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jar and i tried with this also set CATALINA_OPTS= -javaagent:D:\log4jproject\aspectjweaver-1.8.5.jarIodic

© 2022 - 2024 — McMap. All rights reserved.