<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LoadRunner TnT &#187; Java</title>
	<atom:link href="http://www.loadrunnertnt.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.loadrunnertnt.com</link>
	<description>Performance Testing, LoadRunner Tips &#38; Tricks</description>
	<lastBuildDate>Mon, 08 Mar 2010 07:57:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Achieving High Performance Application in Java Coding! – Part 3</title>
		<link>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-3/</link>
		<comments>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-3/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 15:22:07 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimizing]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=694</guid>
		<description><![CDATA[Code with performance in mind!  Follow these next 7 good coding practises that can be easily achieved for high performance!

Beware of “Thread.run()” versus the real intend of “Thread.start()” – We may unknowingly code the thread as “run()”.  This will cause the thread to run sequentially instead of concurrently. Beware of this!  Use “Thread.start()” to allow [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.loadrunnertnt.com/wp-content/uploads/2010/02/web_coding_collage-150x150.jpg"><img class="size-full wp-image-698 alignright" title="web_coding_collage-150x150" src="http://www.loadrunnertnt.com/wp-content/uploads/2010/02/web_coding_collage-150x150.jpg" alt="" width="81" height="81" /></a>Code with performance in mind!  Follow these next 7 good coding practises that can be easily achieved for high performance!<span id="more-694"></span></p>
<ul>
<li><strong>Beware of “Thread.run()” versus the real intend of “Thread.start()”</strong> – We may unknowingly code the thread as “run()”.  This will cause the thread to run sequentially instead of concurrently. Beware of this!  Use “Thread.start()” to allow the thread to run concurrently.</li>
<li><strong>Use “String.length ()  == 0” instead of “String.equals(“”)”</strong> – Both constructs do the same thing of comparing if any characters exists for the string. However, the first construct, “String.length() == 0” is more efficient than the latter one.</li>
<li><strong>Avoid calling “String.toCharArray()”</strong> – “toCharArray()” method is inefficient as the method reallocates the entire array stored in the string.  However, sometimes this is necessary.  Therefore, as a rule, avoid using “toCharArray()” method if possible.  If not possible, do use it with care.</li>
<li><strong>Place “try/catch/finally” block outside loop &#8211; </strong>Placing &#8220;try/catch/finally&#8221; blocks inside loops can slow down the execution of code. Do take note that moving the &#8220;try/catch/finally&#8221; block outside the loop can change program behaviour. An exception that has the “try/catch/finally” block outside the loop will terminate early.  On the other hand, the &#8220;try/catch/finally&#8221; block inside the loop may cause the program to continue iterating over the loop even after an exception has occurred.</li>
<li><strong>Use “StringBuffer.Append ()” instead of “+=” operators for concatenating strings </strong>– “Append()” has better improvement over “+=” operators and its recommended to use it instead of “+=” operators for concatenating strings.</li>
<li><strong>Do not use “StringBuffer” as constants </strong>– Dynamically resizable strings are unnecessary for constant strings (as they do not change).  Instead, use “String” for non-modifiable string constants.</li>
<li><strong>Do not open or close JDBC connections in loops </strong>– It is inefficient to open and close a connection in loop.  Instead, the connection should be opened before the loop and closed after the loop to avoid redundant calls make to the database.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Achieving High Performance Application in Java Coding! – Part 2</title>
		<link>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-2/</link>
		<comments>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-2/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 07:25:01 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[finalize]]></category>
		<category><![CDATA[garbage collection]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[optimizing]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=666</guid>
		<description><![CDATA[Following our high performance application in java coding:

Handle the appropriate exceptions (checked); do not leave it to the unchecked exceptions – When an exception is thrown, the runtime system will exhaustively search all the methods on the call stack for the appropriate exception handler.  This is expensive and thus we want to minimize the search [...]]]></description>
			<content:encoded><![CDATA[<p>Following our <a href="../coding/achieving-high-performance-application-in-java-coding/">high performance application in java coding</a>:<a href="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/web_coding_collage-150x1502.jpg"><img class="alignright size-full wp-image-702" title="web_coding_collage-150x150" src="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/web_coding_collage-150x1502.jpg" alt="" width="71" height="71" /></a><span id="more-666"></span></p>
<ul>
<li><strong>Handle the appropriate exceptions (checked); do not leave it to the unchecked exceptions</strong> – When an exception is thrown, the runtime system will exhaustively search all the methods on the call stack for the appropriate exception handler.  This is expensive and thus we want to minimize the search in the call stack in finding the appropriate exception handler to improve performance which can be achieved by throwing and catching the appropriate exceptions (checked exceptions).  Do not leave exception handling as an after-thought or code-as-you-go during development.</li>
<li><strong>Do not incorporate exception handling as control flow</strong> – As mentioned earlier, exceptions are expensive and should only be used for abnormality (planned and unplanned).  An if-then-else construct will perform better without the exception handling as there is no need to transfer control to locate the appropriate exception handling.   As such, review the codes and remove any throw statements from the coding that are used in an if-then-else construct.</li>
<li><strong>Avoid and remove the use of Reflection API in the codes</strong> – Reflection involves types that are dynamically resolved, which restricts optimization in certain JVMs.  Consequently, reflective operations have slower performance than non-reflective counterparts.  Therefore, unless there is a dire need for reflection to be used in the java program, it is best to leave it out if you need a high performance program.</li>
<li><strong>Let the system decide the garbage collection</strong> – If possible, remove any attempt to call system.gc(). system.gc() triggers a full collection , which includes tracing all live objects in the heap and sweeping and compacting the old generation. This can be a lot of work. In general, it is better to let the system decide when it needs to collect the heap, and whether or not to do a full collection.  Note: system.gc() merely signals (marks) the java program to do garbage collection, but it will not be an immediate garbage collection taking place.</li>
<li><strong>Reduce memory by avoiding the use of finalizers </strong>– An object is in the <em>finalized</em> state if it is still unreachable after running the finalize method, if any, has been run.  The finalized object is then awaiting deallocation and deallocation will not take place until the finalizer is run which is dependent on the VM.  The use of finalizer will extend the lifetime of the <em>finalized</em> object and it can be counter-intuitive when no deallocation takes place and when you intended to have the object being short-lived.   In order to avoid these short-lived objects being extended during the lifetime of the heap memory, it is best to consider the use of finalizers or free the resources explicitly.   (Source: <a href="http://java.sun.com/docs/books/performance/1st_edition/html/JPAppGC.fm.html">Appendix A, The Truth About Garbage Collection</a> and <a href="http://www.ibm.com/developerworks/library/j-jtp01274.html">Java theory and practice: Garbage Collection and Performance</a>)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Achieving High Performance Application in Java Coding!</title>
		<link>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding/</link>
		<comments>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 07:20:14 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[memory leaks]]></category>
		<category><![CDATA[optimizing]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[substring]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=620</guid>
		<description><![CDATA[High performance web sites and applications can start from the design coding level.  Most of the time, performance tuning we view comes at the later stage of the development life cycle, in particular at the deployment stage.  What can we do by deployment stage?  We can only tune start up parameters, add more hardware, or [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/web_coding_collage.jpg"><img class="alignleft size-thumbnail wp-image-633" title="web_coding_collage" src="http://www.loadrunnertnt.com/wp-content/uploads/2010/01/web_coding_collage-150x150.jpg" alt="" width="86" height="86" /></a>High performance web sites and applications can start from the design coding level.  Most of the time, performance tuning we view comes at the later stage of the development life cycle, in particular at the deployment stage.  What can we do by deployment stage?  We can only tune start up parameters, add more hardware, or add more network components in the architecture.  But what if the problem is in the JVM where you diagnose it to be poor application performance due to coding?  Changing codes at this stage will be more expensive and difficult unlike when you are in the development stage!<span id="more-620"></span></p>
<p>How can we build a high performance web site through coding then?  Here are some basic tips you should note during development which should not be a big hassle for you to make changes anytime!<strong> </strong></p>
<p><strong>1. Remove any unused      variables – </strong>The first thing and most simple thing you can do is to avoid      creating unused variables.  Use      static code analysers and look for variables that are initialized but not      used.  Sometimes, in the midst of      development, we leave out variables that aren’t used anymore and this can      be removed to converse memory.<strong></strong></p>
<p><strong>2. Free all resources – </strong>All created resources      and variables should be released once they are not used.  This helps converse memory.  This will help optimize the memory usage      and thus reduce the need for garbage collection cycle to take place.  Resources such as database connections      and files are simple examples that you should close and release the      resources.<strong></strong></p>
<p><strong>3. Free all resources in      the ‘finally’ block – </strong>Similar to [2], we want to free all      resources.  However, this is catered      to “unhappy” flow of the program code.       Free all resources that are used when exception arises if applicable.<strong></strong></p>
<p><strong>4. Avoid calling methods in loops – </strong>This can be circumvented when the compiler optimizes the code.  However, if it doesn’t the loop condition will be calculated for each iteration during the loop</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">// bad practise</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MethodInLoop <span style="color: #009900;">&#123;</span><br />
<span style="color: #000066; font-weight: bold;">void</span> method <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Avector+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Vector</span></a> vector<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> vector.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// do something</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// good practise</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MethodOutOfLoop <span style="color: #009900;">&#123;</span><br />
<span style="color: #000066; font-weight: bold;">void</span> method <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Avector+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Vector</span></a> vector<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000066; font-weight: bold;">int</span> size <span style="color: #339933;">=</span> vector.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> size<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">// do something</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p><strong>5. Avoid methods that may      cause memory leaks – </strong>Methods such as split(java.lang.String),      split(java.lang.String, int), substring(int), substring(int,int),      nextElement(), nextToken(), nextToken(java.lang.String), group() and      group(int) are candidates of memory leak.       There are quite a fair bit of search results on the methods that      causes memory leaks.  You can refer      to <a href="http://eyalsch.wordpress.com/2009/10/27/stringleaks/">“Strings      and Memory Leaks”</a> from The Java Explorer for some information.  Avoid such methods whenever      possible.  If not, do use it with      care.</p>
<p>More to come on coding for high performance applications!  Share with us on your performance coding tips here too! <img src='http://www.loadrunnertnt.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/coding/achieving-high-performance-application-in-java-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zyntax: Java Serialized Stream Extension</title>
		<link>http://www.loadrunnertnt.com/products/zyntax-java-serialized-stream-extension/</link>
		<comments>http://www.loadrunnertnt.com/products/zyntax-java-serialized-stream-extension/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 16:35:22 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Products]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=33</guid>
		<description><![CDATA[If you are working with IBM Rational Robot and TestManager, and working with Java Serialized Stream, you may consider this 3rd party extension, JSS Extension from Zyntax. Usually serialized streams are not viewable by the user and this creates the challenge of customizing the serialized streams.  The JSS Extension transforms raw socket data in previously [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Zyntax" src="http://loadrunnertnt.com/images/company_zyntax.jpg" alt="" width="210" height="52" />If you are working with <strong>IBM Rational Robot</strong> and <strong>TestManager</strong>, and working with Java Serialized Stream, you may consider this 3rd party extension, <a title="Zyntax: Java Serialized Stream Extension" href="http://www.zyntax.com/index.php?option=com_content&amp;view=article&amp;id=91&amp;Itemid=114" target="_blank">JSS Extension from Zyntax</a>. Usually serialized streams are not viewable by the user and this creates the challenge of customizing the serialized streams.  The JSS Extension transforms raw socket data in previously recorded test scripts into lines that separate and identify the data elements of the Java Objects being transferred. The newly formed scripts can then be used to perform load, stress, and performance testing and benchmarking against the application.<span id="more-33"></span></p>
<p>Of course, its not free.  To request an evaluation or see JSS pricing see the JSS Request page.  For more information of this extension, you can refer to the provider&#8217;s website at <a title="Zyntax: Java Serialized Stream Extension" href="http://www.zyntax.com/index.php?option=com_content&amp;view=article&amp;id=91&amp;Itemid=114" target="_blank">Zyntax Consulting</a>.</p>
<p>About Zyntax Consulting, refer to <a title="About Zyntax Consulting" href="http://www.zyntax.com/index.php?option=com_content&amp;view=article&amp;id=68&amp;Itemid=124" target="_blank">Zyntax Consultin, About Us</a>.</p>
<p><a title="CSS Corp" href="http://www.csscorp.com/" target="_blank">(Special thanks to Aravind Kumar for contribution, CSS Corp)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/products/zyntax-java-serialized-stream-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java.lang.NoClassDefFoundError: jhook/HookMetaData</title>
		<link>http://www.loadrunnertnt.com/errors/java-lang-noclassdeffounderror-jhookhookmetadata/</link>
		<comments>http://www.loadrunnertnt.com/errors/java-lang-noclassdeffounderror-jhookhookmetadata/#comments</comments>
		<pubDate>Wed, 13 Aug 2008 21:22:23 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jhook]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=170</guid>
		<description><![CDATA[The NoClassDefFoundError for Java-RMI protocol. There are several possibilities that this error occur such as (a) incomplete configuration of the Java environment requirements (refer to &#8220;Working with RMI-Java&#8221;), (b) incomplete reference to the Java libraries (usually located in {loadrunner-installation}\classes and {loadrunner-installation}\classes\srv after the required copy of the application&#8217;s Java classes are placed in them) and [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>NoClassDefFoundError</strong> for Java-RMI protocol. There are several possibilities that this error occur such as (a) incomplete configuration of the Java environment requirements (refer to <a title="Working with RMI-Java" href="articles/29-how-tos/48-working-with-rmi-java" target="_blank">&#8220;Working with RMI-Java&#8221;</a>), (b) incomplete reference to the Java libraries (usually located in <em>{loadrunner-installation}\classes</em> and <em>{loadrunner-installation}\classes\srv</em> after the required copy of the application&#8217;s Java classes are placed in them) and (c) incorrect -Xbootclasspath to inform VUgen to point to the Java libraries for recording.</p>
<p><span id="more-170"></span>The error message that is thrown upon when the<em> bootclasspath</em> was not specified in the recording options is shown below:</p>
<div class="codecolorer-container dos default" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">java.lang.NoClassDefFoundError: jhook/HookMetaData<br />
at java.rmi.Naming.lookup<span style="color: #66cc66;">&#40;</span>Naming.java<span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.ClientRMI.getRemoteModuleImpl<span style="color: #66cc66;">&#40;</span>ClientRMI.java:<span style="color: #cc66cc;">256</span><span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.ClientATPRemoteEx.getRemoteModule<span style="color: #66cc66;">&#40;</span>ClientATPRemoteEx.java:<span style="color: #cc66cc;">89</span><span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.ClientATPRemoteEx.getRemoteModule<span style="color: #66cc66;">&#40;</span>ClientATPRemoteEx.java:<span style="color: #cc66cc;">64</span><span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.VirtualRemoteServer.setupPingRemote<span style="color: #66cc66;">&#40;</span>VirtualRemoteServer.java:<span style="color: #cc66cc;">102</span><span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.VirtualRemoteServer.pingServer<span style="color: #66cc66;">&#40;</span>VirtualRemoteServer.java:<span style="color: #cc66cc;">166</span><span style="color: #66cc66;">&#41;</span><br />
at pie.engine.atp.CacheTimer$1.run<span style="color: #66cc66;">&#40;</span>CacheTimer.java:<span style="color: #cc66cc;">47</span><span style="color: #66cc66;">&#41;</span><br />
at java.util.TimerThread.mainLoop<span style="color: #66cc66;">&#40;</span>Timer.java:<span style="color: #cc66cc;">432</span><span style="color: #66cc66;">&#41;</span><br />
at java.util.TimerThread.run<span style="color: #66cc66;">&#40;</span>Timer.java:<span style="color: #cc66cc;">382</span><span style="color: #66cc66;">&#41;</span></div></div>
<p>To resolve the error was straight forward, enter the following to (a) the additional startup command to the recording options or (b) add it to the command batch file that is launching the Java application:</p>
<p>-Xbootclasspath/p:&#8221;D:\Program Files\LoadRunner\classes;D:\Program Files\LoadRunner\classes\srv&#8221;</p>
<p><!--adsensestart--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/errors/java-lang-noclassdeffounderror-jhookhookmetadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing Java recording in LoadRunner!</title>
		<link>http://www.loadrunnertnt.com/concepts/introducing-java-recording-in-loadrunner/</link>
		<comments>http://www.loadrunnertnt.com/concepts/introducing-java-recording-in-loadrunner/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 04:50:50 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[Concepts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[LoadRunner]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=277</guid>
		<description><![CDATA[LoadRunner provides the capability of load testing Java-related applications. If you are new and unfamiliar with how LoadRunner works and the relations with protocols, I would recommend to review &#8220;What&#8217;s LoadRunner?&#8221; and &#8220;Which protocol to use?&#8221; to have an understanding before proceeding. In this article, we will provide a brief introduction to working with Java-related [...]]]></description>
			<content:encoded><![CDATA[<p>LoadRunner provides the capability of load testing Java-related applications. If you are new and unfamiliar with how LoadRunner works and the relations with protocols, I would recommend to review <a title="What’s LoadRunner?" href="http://www.loadrunnertnt.com/?p=17" target="_blank">&#8220;What&#8217;s LoadRunner?&#8221;</a> and <a title="Which protocol to use?" href="http://www.loadrunnertnt.com/?p=305" target="_blank">&#8220;Which protocol to use?&#8221;</a> to have an understanding before proceeding. In this article, we will provide a brief introduction to working with Java-related applications in LoadRunner that you will have to take note.<span id="more-277"></span></p>
<p><span style="text-decoration: underline;">1. Introduction</span></p>
<p>Before we start choosing Java-related protocols to perform recording, you will need to understand the protocol that the Java application is using to communicate with the server. It maybe the case where the Java application is communicating via <strong>HTTP</strong> rather than <strong>RMI-Java</strong>, etc… If you have identified that the application is communicating with a Java related protocol, you can safely proceed to choose the relevant Java protocol.</p>
<p style="float: right; margin-right: 8px;">
<p>For Java-related protocol, the recording works in the same way as <strong>.NET</strong> and <strong>COM/DCOM</strong> protocol. All of them share the same characteristics but I will specify to just Java and only Java recording. Pure Java <strong>scripting</strong> will be excluded in this article.</p>
<p>Unlike .NET and COM/DCOM, Vugen provides an interface to manage and <strong>filter</strong> the classes and methods via the GUI which is very convenient to the user. Hopefully, Mercury/HP may consider that in future.</p>
<p><span style="text-decoration: underline;">2. Classes and Methods</span></p>
<p>You will need the knowledge of the <strong>classes</strong> and <strong>methods</strong> prior recording; and usually this information is held by the developers. The need to know the classes and methods is crucial because, <strong>LoadRunner (Vugen)</strong> implements a <strong>hooking mechanism</strong> to hook the traffic on the classes.</p>
<p style="float: right; margin-right: 8px;">
<p>If you do not know what classes are needed for the load test, and allow LoadRunner to capture all <strong>traffic</strong> on the classes, you may result in excessive capturing such as <strong>GUI</strong> clicks or <strong>client activities</strong>. On the other hand, if you did not specify the actual classes involve in the load test, you may miss out on the real class being used.</p>
<p>The above mention is based on the default Java hooking mechanism that LoadRunner implements. But if you required to have additional classess you need to record, you will need to configure the hooking mechanism that will be covered in subsequent post. This is also the reason the knowledge of the classes and methods come in important.</p>
<p><span style="text-decoration: underline;">3. JDK and JRE</span></p>
<p>Other than the knowledge of the <strong>classess</strong> and <strong>method</strong>, you will need to know the JDK of the application. By default, Sun Microsystems <strong>JDK</strong> (SDK) works with LoadRunner.</p>
<p>There will be scenarios that your application is not using te Sun JDK such as <strong>IBM JDK</strong>. If that is the case, my advise is to check with Mercury/HP on the <strong>compatibility</strong> level and this will save you lots of effort. In my experience, usually they are not as fully supported as compared to Sun JDK.</p>
<p>The minimum supported JDK is JDK 1.3 for <strong>LoadRunner 8.1</strong> as of this writing. Take note that the recording is still very dependant on the JDK version installed. That is, if your application is JDK 1.6, you will have to install this version on the recording machine.</p>
<p>Lastly, <strong>JRE</strong> is insufficient for the recording to be successful. Ensure that JDK is installed.</p>
<p><span style="text-decoration: underline;">4. Recording-specified</span></p>
<p style="float: right; margin-right: 8px;">
<p><strong>LoadRunner Vugen</strong> implements an API that hooks into the selected classes and record the traffic. Therefore, as pointed earlier, knowing the correct <strong>classes</strong> to hook is crucial.</p>
<p>With the hooking in place, GUI classes or client-side activities maybe recorded via the hook. However, this is not recommended as it does not contribute to the load generation towards the server. I will share with you the recording details in another article. Do stay tuned for it.</p>
<p><span style="text-decoration: underline;">5. Scenario Execution</span></p>
<p>Prior the scenario execution in the <strong>Controller</strong>, ensure that <strong>JDK</strong> have be installed on the Load Generators. The scripts sent (refer to the article,<a title="4 Points to note for Scenario Execution!" href="http://www.loadrunnertnt.com/?p=279" target="_blank">&#8220;4 points to note for Scenario Execution&#8221;</a> for more information) are Java scripts, and require <strong>JVM</strong> to run.</p>
<p><span style="text-decoration: underline;">6.Documentations</span></p>
<p>If you like to know more information from the official provider, you can refer to the <strong>Vugen User Guide</strong> that is provided in each installation of <strong>LoadRunner</strong> in PDF format. Specifically the following chapters:</p>
<ul>1. All chapters in Part II: Working with Java Language Protocols<br />
2. Chapter 18: Developing Corba-Java Vuser Script<br />
3. Chapter 19: Developing RMI-Java Vuser Scripts.</ul>
<p><span style="text-decoration: underline;">7. Samples</span></p>
<p>Also, if you like to get a feel of working with <strong>Java protocol</strong>, I would recommend using the sample example provided with every installation of LoadRunner. It will at least get you understand what will happened and the expected output when recording Java language applications.</p>
<p>That comes to the end of the introduction of the workings of <strong>Java language protocol</strong> in LoadRunner, things to watch out and additional resources to pertaining to the topic. Do take note that Java is not as straight-forward as Web(HTTP/HTML) and therefore give it additional attention when working on such load testing projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/concepts/introducing-java-recording-in-loadrunner/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working with RMI-Java</title>
		<link>http://www.loadrunnertnt.com/how-tos/working-with-rmi-java/</link>
		<comments>http://www.loadrunnertnt.com/how-tos/working-with-rmi-java/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 04:13:02 +0000</pubDate>
		<dc:creator>TnT Admin</dc:creator>
				<category><![CDATA[How-Tos]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scripting]]></category>

		<guid isPermaLink="false">http://www.loadrunnertnt.com/?p=100</guid>
		<description><![CDATA[
This document is intended for an audience that is unfamiliar with the RMI-Java protocol or Java Technology. Follow the below procedures, step-by-step sequence to ensure that the Java application can be invoked and recorded properly. If you failed at any point of step, apply the appropriate solution before proceeding to the next step as the [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Java" src="http://loadrunnertnt.com/images/java_logo.png" alt="" width="115" height="127" /></p>
<p>This document is intended for an audience that is unfamiliar with the <span style="font-weight: bold;">RMI-Java protocol</span> or <span style="font-weight: bold;">Java</span> Technology. Follow the below procedures, step-by-step sequence to ensure that the Java application can be <span style="font-weight: bold;">invoked</span> and recorded properly. If you failed at any point of step, apply the appropriate solution before proceeding to the next step as the sequence below is designed to ensure that all requirements are met for the recording to succeed.</p>
<p>What we want to achieve in an overview is as followed:</p>
<p><span id="more-100"></span></p>
<ol>
<li>Ensure the Java application can be launched outside <span style="font-weight: bold;">Vugen</span>.</li>
<li>Setup the Java environment for recording.</li>
<li>Ensure that an empty <span style="font-weight: bold;">RMI-Java</span> vuser can be replayed to verify Java environment.</li>
<li>Ensure the Java application can launch</li>
<li>Ensure the recording causes the “green box” to launch</li>
<li>Ensure the events are recorded after the “green box” launched.</li>
</ol>
<p>This document also compliments <a title="dRunner Java Environmental Requirements" href="http://support.openview.hp.com/selfsolve/document/KM170107" target="_blank">Document ID 11878, &#8220;LoadRunner Java Environmental Requirements&#8221;</a> which described the requirements needed for <span style="font-weight: bold;">LoadRunner</span> to <span style="font-weight: bold;">record</span> and <span style="font-weight: bold;">replay </span>Java-recorded scripts. Much is said, let’s walkthrough the steps together now.</p>
<p><span style="text-decoration: underline;">[1] Launch the application outside VuGen</span></p>
<p>This is the basic verification as we want to know if the Java application can work first even before recording in Vugen. This will help to reduce the troubleshooting effort.</p>
<p><span style="text-decoration: underline;">[2] Setup the Java environment </span></p>
<p>This is to setup all required environment as required in <a href="http://support.openview.hp.com/selfsolve/document/KM170107%20target="><span style="text-decoration: underline;"><span style="color: #0066cc;">Document ID 11878, “LoadRunner Java Environmental Requirements”</span></span></a> are met before we can proceed to record/replay on the local machine. Take about 15 minutes to read and go through the document.</p>
<p><span style="text-decoration: underline;">[3] Verify the Java environment setup in [2]</span></p>
<p>Create an empty RMI-Java VUser and replay it. If the replay encounter no error, the setup is valid. If not, then rework on point [2] to correct the Java environment.</p>
<p><span style="text-decoration: underline;">[4] Proceed to record the RMI-Java VUser</span></p>
<p>If all is setup properly and the supported <span style="font-weight: bold;">JDK</span> are installed,<span style="font-weight: bold;"> Vugen</span> should be able to record. If not, proceed to [5].</p>
<p><span style="text-decoration: underline;">5] If application does not launch during recording</span></p>
<p>The most likely cause of the problem is that the <span style="font-weight: bold;">classes</span> are not loaded which maybe missing from the CLASSPATH. Without the definition of the classes in the <span style="font-weight: bold;">CLASSPATH</span>, the application may not be able to launch. To resolve this problem, ensure the <span style="font-weight: bold;">CLASSPATH</span> is set properly.</p>
<p>a. Use <span style="font-weight: bold;">javap.exe</span> (available in <span style="font-weight: bold;">JDK</span> only) on the command line to check the missing method or class. To use javap.exe, run: javap.exe (without the “.class” suffix). When the class is not in the CLASSPATH, you will get the following error message: <span style="font-weight: bold;">‘Class not found</span>’. Otherwise you will receive all its fields and methods. For more information of javap.exe, you can refer to <a href="http://mindprod.com/jgloss/javapexe.html" target="_blank"><span style="text-decoration: underline;"><span style="color: #0066cc;">MindProd</span></span></a> and <a href="http://java.sun.com/javase/6/docs/technotes/tools/windows/javap.html" target="_blank"><span style="text-decoration: underline;"><span style="color: #0066cc;">Sun Microsystem</span></span></a>.</p>
<p>From here, look at the missing classes. If there are missing classes, obtain a copy from the developers of the application, and placed them into the <span style="font-weight: bold;">CLASSPATH</span> (including the classes directory you’ve defined for the recording).</p>
<p>b. Use <span style="font-weight: bold;">Java-Plugin</span> to identify the error message. Troubleshoot the error accordingly. For the plugin, it will throw the exception into its console. You will have to turn on the Java Console (in Control Panel &gt; Java &gt; “Advanced” Tab &gt; Select “Show Console” in order to capture the exception or information. If exceptions were captured in the console, look at the error message and troubleshoot from there. As the exceptions may vary, you will have to see what is been thrown out in order to resolve the problem and we won’t be able to advise on it. (NOTE: The steps for the <span style="font-weight: bold;">Java Console</span> is based on JRE 1.5.0_06, therefore it may vary with other versions of Java Plugin.)</p>
<p><span style="text-decoration: underline;">[6] If application launches but not recording (Green box illustrated below does not launch)</span></p>
<p align="center"><a href="http://loadrunnertnt.com/images/java_recording_dialogue.JPG"><span style="text-decoration: underline;"><img title="java recording loadrunner" src="http://loadrunnertnt.com/images/java_recording_dialogue.JPG" border="0" alt="java recording loadrunner" width="200" height="49" /></span></a></p>
<p>The problem can be caused where the default <span style="font-weight: bold;">hooking mechanism</span> is not loaded. To resolve the problem, follow the below suggestions for hooking mechanism.</p>
<p>a. Try running the<span style="font-weight: bold;"> -Xrunjdkhook</span> outside <span style="font-weight: bold;">VuGen</span> via a <span style="font-weight: bold;">.bat</span> file. This is an easy way to verify the command statement with -Xrunjdkhook is working fine when invoking outside of VuGen. If it fails, you can proceed to (b), else look at the additional notes section to see if it fulfill any of the points mentioned.</p>
<p>b. Ensure that the hook files are properly set.</p>
<p>c. If you are doing custom hooking, verify that the hooks are properly configured with reference to the <a href="http://support.openview.hp.com/selfsolve/document/KM169636" target="_blank"><span style="text-decoration: underline;"><span style="color: #0066cc;">“Document ID 11287 &#8211; How to do Java custom hooking”</span></span></a>.</p>
<p>d. Verify <span style="font-weight: bold;">-Xrunjdkhook</span> exist in the arguments passed to invoke the <span style="font-weight: bold;">Java</span> application. Below is a sample command line.</p>
<ul><em>SET java -Xrunjdkhook -Xbootclasspath/p:\classes;\classes\srv -jar javaapp.jar</em></ul>
<p>e. Ensure the file <span style="font-weight: bold;">user.hooks</span> is placed in <span style="font-weight: bold;">\classes</span>.</p>
<p>f. Verify the content of <span style="font-weight: bold;">cjhook.ini</span></p>
<p>g. Look at the errors associated with hooking mechanism; this can be achieved with the following steps.</p>
<ol>Enable in recording options &gt; Recording Properties &gt; Debug Options.<br />
Enable all checkboxes, and set “Hooking Options” &gt; “Printout Redirections” to “File” instead of “Console”.</ol>
<p>After doing so, useful debugging information will be saved during recording in the file <span style="font-weight: bold;">“/data/console.log”</span>, and “/data/console2.log”.</p>
<p><span style="text-decoration: underline;">[7] No events or hang recorded after Green Recording box is launched</span></p>
<p>This maybe a result of class files not correctly configured in the CLASSPATH. To resolve the problem, rework to step [5] and apply the solutions.</p>
<p><span style="text-decoration: underline;">[8] Try on another machine</span></p>
<p>When all else fails, try it on another machine to verify if it is feasible to record the Java application. If this still fails, look at the Additional Notes section to verify if your Java application is compatible for recording.</p>
<p><span style="text-decoration: underline;">Additional Notes</span></p>
<p>These are points to note when you are working with <span style="font-weight: bold;">RMI-Java</span>.</p>
<p><span style="font-weight: bold;">1. JDK vs. JRE </span></p>
<p>It is required that <span style="font-weight: bold;">JDK</span> be installed instead of JRE as JRE is not sufficient for successful recording</p>
<p><span style="font-weight: bold;">2. Is the JDK a supported version?</span></p>
<p>With the JDK information, it’s best to ensure the <span style="font-weight: bold;">JDK </span>is supported by Vugen (although it is highly dependant on the JDK that you installed). The supported JDK is Sun JDK. Other JDKs such as <span style="font-weight: bold;">IBM JDK </span>is not supported by Vugen and may need to engage consultation services to work around it or study the feasiblity.</p>
<p><span style="font-weight: bold;">3. Is QTP installed on the machine?</span></p>
<p><span style="font-weight: bold;">QTP</span> may conflict with <strong>LoadRunner</strong> Java environment variables as Vugen maybe misled to use the QTP CLASSPATH. As such, you can either uninstall QTP or use another machine.</p>
<p><span style="font-weight: bold;">4. Record from a new machine</span></p>
<p>Sometimes, the settings on the problamtic machine maybe different and it will be an easy option to use a different machine to find out if there are any differentiating parameter between the two.</p>
<p><span style="font-weight: bold;">5. Importance of CLASSPATH and classes</span></p>
<p>Vugen rely heavily on the <span style="font-weight: bold;">CLASSPATH</span> to determine the <span style="font-weight: bold;">classes</span> to load for recording. Therefore, (1) always ensure the CLASSPATH has all the entries of the application before the recording and (2) the classes from the application existed physically in the classes folder that the CLASSPATH points to.</p>
<p>The above should sum up the steps to ensure successful recording. However, do take note of the points in Additional Steps so as to reduce the effort required to work with this protocol.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.loadrunnertnt.com/how-tos/working-with-rmi-java/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

