On increasingly rare occasions, you might be required to load test an application that has a Java-based client. While it’s nice for users to have an application that has a rich GUI, it will probably lead to a world of pain for you as a performance tester.

Don’t immediately reach for LoadRunner’s Java Record-Replay virtual user type. It might not be the right solution.

LoadRunner's Java Record-Replay vuser

This article will guide you through your first steps when selecting the correct vuser type to test an application with a Java-based client…

There are several LoadRunner vuser types that are candidates for your test. Your first task is to pick the correct one. The possible vuser types are:

  • Web (HTTP/HTML)
  • Java
  • Windows Sockets
  • Citrix
  • JAVA Record Replay

HP sells each of these vuser types are in separate license bundles, so you can’t just buy LoadRunner and figure out the vuser type later.

In order to pick the most appropriate virtual user type, you need to know what protocol the Java client uses to communicate with the server. It is best to talk to an architect (or someone else who is suitably technical), but a smart performance tester backs up this conversation by recording the application to see if the architect is correct. You may like to use the LoadRunner Protocol Advisor, but I am old-school, so I record the application with the Windows Sockets vuser, or inspect the network traffic with WireShark.

If you are really lucky, your Java application communicates using HTTP – I had a Java “Web Start” application that just sent SOAP/XML messages to the server. In this case, you can just record using a standard Web (HTTP/HTML) vuser. All your requests will be recorded as web_custom_request, and you can reformat your requests so that they are readable, and do all kinds of neat things with XPath and the lr_xml functions.

The Java vuser is part of the “template” vuser bundle. You can put any Java code you like in these scripts, but there is no ability to record an application. This makes this vuser type only useful for very simple situations where you can confidently rewrite code that will make all the server calls that the client makes – I would only use this vuser type in situations where the application does something trivial like putting a message on a queue.

While you will definitely be able to record your application with the Windows Sockets vuser (winsock), there is only a 1 in a million chance that this is the correct vuser type for you. The basic rule of thumb is: if the captured network traffic that you see is plaintext, and you can figure out the details of the protocol just by eyeballing it for a few seconds, then maybe it is okay to use the winsock vuser type; in all other cases, avoid it. Don’t try to write code in C that will deserialise Java objects.

The Citrix vuser type is like a Get Out of Jail Free card for difficult to script applications. You can bypass all the protocol-level (or method-level) mucking around and just create a script that clicks on the buttons etc in the application. Citrix isn’t the cleanest or most reliable protocol, but a week of hacking at a Citrix script beats many weeks of pain using the Java Record-Replay vuser. Note that you will need to have a Citrix server to run the Citrix vusers against.

Have I dropped enough hints that using the Java Record-Replay vuser type is difficult and not much fun? I have created scripts for a few applications using this protocol now, and it is still not one that I would feel comfortable giving a time estimate for scripting with.

This vuser type works differently from most other vuser types in that it does not record protocol-level traffic, it records Java method calls and their arguments. Obviously if you record every single method call, your script will be huge and unusable, but if you record the method calls that are close to the point where data is sent to the server (while avoiding the low-level java.net classes), you might be able to massage your script into something that actually sends the same requests as the real application.

“Hooks” files instruct the recording engine which methods to record. They will look kind of familiar to people who are used to customising HP Diagnostics. Here is an example from my user.hooks file…

[oracle.jdbc.driver.OracleStatement]
;---------- oracle.jdbc.driver.OracleStatement --------
class      = oracle.jdbc.driver.OracleStatement
method     = executeQuery
signature  = !.*
cb_class   = mercury.corba.CORBASupport
general_cb = true

If you look for files with a .hooks extension under your LoadRunner directory, you will see hooks files for four main protocols RMI, CORBA (BEA Weblogic, Iona OrbixWeb, Visigenic/Inprise Visibroker), JMS, Jacada; and various extensions and JNDI, EJB, JNDI, JTA, ORBacus etc.

LoadRunner Java Record-Replay protocols

Even if your protocol is listed, don’t get too excited. It won’t necessarily work without lots of tweaking. If you need to develop your own custom points file (user.hooks) for your application, it is even more effort work. Don’t expect to be able to do anything useful with this virtual user type unless you have a solid Java background.

The good news (I guess), is that this vuser type will be able to (eventually) record and replay any Java-based application. The bad news is that you may not be able to get it working by yourself – I have seen smart people reduced to helplessness by this vuser type.

Don’t try to do it when you are on a tight deadline. And don’t assume that just because you can record something from your application with this vuser type with the out of the box configuration, that you will be able to get your script to replay successfully (or accurately) without a lot of hard work.

If I have a choice (and the Web vuser does not work), I would always prefer to use Citrix, rather than battle with the Java Record-Replay vuser again.

Further reading…

Five years ago I wrote an article called Tips for Load Testing CORBA Applications with LoadRunner. It still has good information. Also, you will need to read the referenced Mercury document on Custom Hooking.

I also wrote a post specifically about how to record a JDBC application with VuGen (lots of duplication with this article). I have only scripted one Java application which communicates over JDBC (Syndesis TrueSource), but this still took a long time even though the JDBC interface is quite simple.

Good luck with your scripting. Choose your vuser type wisely. 🙂

 

Published On: July 29, 2010Tags: ,

8 Comments

  1. CK October 3, 2010 at 1:13 pm - Reply

    Good post. Would be interested to see what you think about the new “Java over HTTP” protocol in LoadRunner 11 to see if it changes your outlook.

  2. Henco Lategan October 14, 2010 at 7:44 pm - Reply

    I have a problem with Java Record and Replay the DTO’s . Here is a few lines of code.

    _retrieveepsilonrundaterequest1 = (za.co.sanlam.epsilon.commoncomponent.service.businesscalendarmanager.dto.RetrieveEpsilonRunDateRequest)lr.deserialize(_string1,0);

    THE ERROR ON REPLAY

    C:\Documents and Settings\e924996\Local Settings\Temp\noname47\Actions.java:97: package za.co.sanlam.epsilon.commoncomponent.service.businesscalendarmanager.dto does not exist
    _retrieveepsilonrundaterequest1 = (za.co.sanlam.epsilon.commoncomponent.service.businesscalendarmanager.dto.RetrieveEpsilonRunDateRequest)lr.deserialize(_string1,0); // RMIComponent

  3. Tom April 6, 2011 at 7:26 pm - Reply

    I have one client/server application.Which was recorded using Oracle(2-tier) protocol well before.Now when i try to record this application (new version) with the same protocol nothing is recording.what may be the problem?

  4. Llorenç October 4, 2011 at 8:43 pm - Reply

    Desperate situation, no way to record a JavaRichClient app, we try with Java Record Replay the app start ok but no events at all were recorded, in fact our application communicates via JOLT API with a HOST, but in LR 9.52 JOLT protocol was discontinued, and we’re unable to figure which protocol to use to create a HOOK (RMI don’t work) so absolute insane situation, a lot of efforts but no results

  5. Megha Pathak December 14, 2011 at 4:56 pm - Reply

    Thanks for a nice and helpful artical on Java protocola. I need to develop a script using Java Record and Replay script, but now thinking of giving it a try with Citrix.

  6. nanmugan December 5, 2012 at 10:52 pm - Reply

    thanks for a nice helpful artical on java protocola.

  7. Sentie77 May 16, 2013 at 11:26 pm - Reply

    Thanks a lot, even its’s a litte bit frustrating to read that even an expert like you with some years of experience didn’t do much with java, because HP has no one who can support us in developing usefully scripts to test our java-richclient with weblogic servers, IBM Host z/OS, Oracle-DBs, and so in multi-tier-architecture

  8. Raghavendra April 9, 2014 at 7:16 pm - Reply

    i’m facing a problem while recording the script using ajax click and script protocol because of all the objects aere not captured.
    could any one help me to get rid out of this issue. early response is appreciated.
    Thanks,
    Raghavendra

Leave A Comment