Thursday, October 29, 2009

YourKit on Your J2EE Server

Most of us as engineers are faced with situations when the problem is not staring at our face, in fact its hiding from us ready to lash out on the JVM once its pushed to production. With the configurations we have and loads we generate in the labs we can never cover all the scenarios that are possible in production. Your Kit is your spy who can get even the trickest bugs out in the open and in front of your eyes in a cool UI. Here are the steps needed for you to set up Your Kit to profile your remote J2EE server.

Setting Up Agent in the Remote Server to be Monitored :

  • Download Linux ZIP archive distribution bundle. The Linux ZIP archive is actually a multi-platform bundle containing all necessary files for each supported platform, thus do not hesitate using it on Solaris, Windows and Mac OS X.

  • Copy the ZIP file to the remote machine and unpack to arbitrary directory. License key is NOT required to run the console version of the integration wizard. Just copy the ZIP and unpack it.

  • Run this command and follow instructions that appear: java -jar <directory with unpacked content>/lib/yjp.jar -integrate ( after you execute the command, YourKit agent will ask you few questions including the server type (Jetty, Jboss etc ) you are running, the location where your server startup script is located... etc. Once you answer these question, a copy of a YourKit version ( usually with name similar to "bin_with_yjp.sh" ) of server startup script is generated, you can copy the JVM option provided in this script and add it to your start up script.


The JVM option in the bin_with_yjp.sh usually is similar to this:

java -agentpath:/export/home/tester/youragent/yjp-8.0.18/bin/solaris-x86-64/libyjpagent.so=disablestacktelemetry,disableexceptiontelemetry,delay=10000,sessionname=Jetty -jar start.jar

In Case of jetty you can add the underlined portion of the above line to your start up script where you provide the JVM CMD arguments: ( you can omit "sessionname=Jetty -jar start.jar", as this might not work in most cases)


  • Note : (1) You need Java 5 or newer to run the command. (2) the integration wizard generates output files (copies of configuration files, additional startup scripts) in directories where original files locate. Please ensure that you run the command with sufficient access rights.


Monitoring from the Your Kit UI Profiler Client :

  • Download Your Kit Profiler Client from here - http://www.yourkit.com/java/profiler/index.jsp , choose based on your OS ( Note : This is the same ZIP file, but you will be installing the Profiler instead of running the jar file as we did while setting up the agent in the remote J2EE server. NOTE : The installation of clinet requires licence and is not free. You can always use the trial version)

  • Once the ZIP file is downloaded, unpack it ( in case of windows, MAC or Linux) and launch by double clicking the Executable found in the folder after unpacking)

  • When you launch the Profiler, you will see a UI with main option, click on the "Connect to the Remote Server". This should bring up a pop up windown, which will ask you to enter the server name you want to monitor. If your remote agent is running, this will work and you can start profiling :) .


Your Kit Profiler How To's :