I want to profile tomcat server with a java profiler. My profiler runs from the script say run.sh which looks like below:
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
JAVACMD="$JAVA_HOME/bin/java"
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly; cannot execute: $JAVACMD"
exit 1
fi
java -javaagent:lib/jborat-agent.jar \
-Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \
-Dch.usi.dag.jborat.liblist="conf/lib.lst" \
-Dch.usi.dag.jp2.outputFilePrefix="output" \
-Dch.usi.dag.jborat.instrumentation="ch.usi.dag.jp2.instrument.AddInstrumentation" \
-Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \
-Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" \
-Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.jar/jp2.jar/jborat-agent.jar/jborat.jar $*
Could somebody please guide me how can I include this profiler in tomcat ?
Is it possible to write something like this CATALINA_OPTS=”$CATALINA_OPTS -javaagent:run.sh” in catalina.sh ?
I would really appreciate any help regarding this.
Thanks.
I tried adding options of run.sh (profiler) to setenv.sh as below but does not work. It does not give any error but The server is not starting. I dont know why.
Here is my setenv.sh file:
#!/bin/sh
export CATALINA_OPTS="java -javaagent:lib/jborat-agent.jar \
-Dch.usi.dag.jborat.exclusionList="conf/exclusion.lst" \
-Dch.usi.dag.jborat.liblist="conf/lib.lst" \
-Dch.usi.dag.jp2.outputFilePrefix="output" \
-Dch.usi.dag.jborat.instrumentation="ch.usi.dag.jp2.instrument.AddInstrumentation" \
-Dch.usi.dag.jp2.dumpers="ch.usi.dag.jp2.dump.xml.XmlDumper" \
-Dch.usi.dag.jborat.codemergerList="conf/codemerger.lst" \
-Xbootclasspath/p:./lib/Thread_JP2.jar:lib/jborat-runtime.jar:lib/jp2-runtime.jar/jp2.jar/jborat-agent.jar/jborat.jar "
I already answered your exact same question yesterday. Briefly, you want this:
I don’t understand why you need more than that: your script just adds a bunch of system properties to the JVM launcher: you can do that with
$CATALINA_OPTS. If you want to set them somewhat permanently, put theexportintobin/setenv.shand it will automatically be run every time you runbin/startup.sh(andbin/shutdown.shfor that matter).