Sunday, February 2, 2014

Configuring JProfiler for WebLogic

Download and install JProfiler 7.2 (the latest is 8 at the time of writing). Enter the licensing information. Run the Session/Integration/New Remote Integration.

Then remote Application Server:

this means that it will generate jprofiler_agent_linux-x64.tar.gz in c:\temp
you must previously have copied (from the DOMAIN_HOME/bin folder) to your c:\temp folder. In the snapshot below I have tried with, but this is NOT recognized as a valid script.... please replace it with script!

as said, is not recognized... use instead!

this time it will work:

and at this point we are ready to attach:

but fiirst you must prepare the Application Server (the Managed Server)

sudo mkdir /opt/jprofiler
sudo chmod soa:soa /opt/jprofiler

The file jprofiler_agent_linux-x64.tar.gz will be created in c:\temp. Copy it to the /opt/jprofiler folder, then:
tar xvzf jprofiler_agent_linux-x64.tar.gz  

and that's it for the libraries.

The modification done in is:  
added on top:

added above this line: echo "starting weblogic with Java version:":
export JAVA_VM
JPROFILER_OPTIONS="-agentpath:/opt/jprofiler/bin/linux-x64/,nowait $JPROFILER_OPTIONS"

echo "starting weblogic with Java version:"

${JAVA_HOME}/bin/java ${JAVA_VM} -version

if [ "${WLS_REDIRECT_LOG}" = "" ] ; then
 echo "Starting WLS with line:"
 echo "${JAVA_HOME}/bin/java ${JPROFILER_OPTIONS} ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME}${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}"
 ${JAVA_HOME}/bin/java ${JPROFILER_OPTIONS} ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME}${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}
 echo "Redirecting output from WLS window to ${WLS_REDIRECT_LOG}"
 ${JAVA_HOME}/bin/java ${JPROFILER_OPTIONS} ${JAVA_VM} ${MEM_ARGS} -Dweblogic.Name=${SERVER_NAME}${WL_HOME}/server/lib/weblogic.policy ${JAVA_OPTIONS} ${PROXY_SETTINGS} ${SERVER_CLASS}  >"${WLS_REDIRECT_LOG}" 2>&1 

The JPROFILER_OPTIONS add a agentpath pointing to the jprofiles libraries in charge of doing the instrumentation and profiling.

BEWARE: if you copy the from a different domain, make sure you change the DOMAIN_HOME !

At this point we must change the and scripts to add the JProfiler libraries.... we shall clone the existing scripts, to allow normal operations to be unaffected.

change the 2 occurrences of into

copy to DOMAIN_HOME/bin the generated by the jprofiler wizard

to start the profield server, run ./ osbpp4ms1 (or whatever is your managed server name).

In the logs you should see:

JProfiler> Protocol version 37
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Don't wait for frontend to connect.
JProfiler> Starting up without initial configuration.
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Hotspot compiler enabled

And you are ready to connect and profile.

Happy profiling!

1 comment:

chetan gupta said...

awesome man, worked for me like a charm

had to change "JPROFILER_OPTIONS" as well to my local location.