Rational purify coverage for J2EE application deployed in Websphere

Code coverage for J2EE applications deployed in Websphere using Rational Purify plus

Rational's purify plus is one of the best code coverage tool I have seen till today, It has multiple capabilities in which I got a chance to work with is code coverage capability. Some times it is required for Developers and testers to know what part of the code is not getting executed, which part is getting executed during specific scenario of usage etc. In this case it is always good to use a code coverage too like purify plus to monitor our application while running and analyze the results of code run.  The general process of code coverage is simple for any normal java applications, but when comes to a J2EE applications deployed and running under Websphere application server as a service needs more settings and configurations. In the web we can find many documents for configuring simple Java applications and other for code coverage.

So this post main aim is to explain the steps to configure the code coverage for J2EE application deployed under websphere and running as a system service.

Environment description : 
 Operating system : Windows XP / 2003
 Webserver / Applicaiton server : Websphere
 Application : J2EE type
Running as : Windows service.

Collect data by changing the WAS configuration file
When the Java process for hosting WAS is initialized, it gets its command line options from the server configuration file. This file exists for every WAS node and every WAS server. The location and name of this file is defined as follows:
<WAS root>\profiles\<your active profile>\config\cells\< cell id>\nodes\<node id>\servers\<server name>\server.xml

For example, if WAS is installed in C:\WAS, the profile name is ‘MyProfile’, the cell id is ‘MyCellId’, the node id is ‘MyNodeId’, and the server name is ‘MyServer’. The configuration file path will be defined like this:

C:\WAS\profiles\MyProfile\config\cells\MyCellId\nodes\MyNodeId\servers\MyServer\server.xml

Ex :
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\ibm-b51282f6ec3Node01Cell\nodes\ibm-b51282f6ec3Node01\servers\CDSServer

For example:
<jvmEntries xmi:id="JavaVirtualMachine_1284026476671" verboseModeClass="false" verboseModeGarbageCollection="false" verboseModeJNI="false" runHProf="false" debugMode="false" debugArgs="-Djava.compiler=NONE -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7777" genericJvmArguments="-DPD_DT_ENABLED=true -XrunPureJVMPI:Coverage" executableJarFileName="-Xbootclasspath/a:%PPLUS_HOME%\Rational.jar" disableJIT="false">

The best way to change the profile is to use the WAS administrative console. However, if you do not have access to the console or do not have sufficient rights to edit the server configuration, you may edit the XML file directly. You should locate the jvmEntries element in this file and change the appropriate VM options by adding the JVMPI loading option: -XrunPureJVMPI:

After saving the file or applying these changes from the administrative console you should restart the server process. After the new instance of WAS starts, it will run with the appropriate profiler attached.

So to do the code coverage for any J2EE applications deployed under web sphere and WAS server is running as a system service. So if we edit prefilters in the default settings, this is not going to have any effect on the running service. This is because PureCoverage is saving the default settings in the folder named "c:\documents and settings\\application     data\rational\purecoverage\coverage.ini"                               
Whereas WAS running as a service is using the configuration file named "c:\documents and settings\localservice\application                    
data\rational\purecoverage\coverage.ini"                               
In other words, the service profile doesn't correspond to the          
PureCoverage profile, therefore they are trying to access different    
default INI files.                                                     

There are several ways to work around this problem:                    
1. Edit prefilters in the application settings, not the default        
settings.                                                              
2. Copy the coverage.ini file from your profile to the service profile 
(see above)                                                            
3. Run WAS as a user process, not as a system service.(User should be same the user with which purify was run)                  
4. Change the user associated with the service to be the same as the one
running the coverage.                                                  
5. Manually edit the coverage.ini file in the local service profile. 

so the best I followed after changing the server.xml file is 3rd one , run you websphere service as the user with which purify coverage was run ... 
Go to Windows 
Start > Run > services.msc > Locate your service ex  : 
IBM WebSphere Application Server V6.1 - CDSServer
> Right click on it > Properties > go to Log on Tab > Select This Account > Provide the user and passwords which is same as the user which is running Purify coverage. > Apply > Ok. 
  • Now launch the Purify coverage once. 
  • Empty coverage window opens up ... 
  • Then now re-strat the Websphere service. 
Now coverage should automatically pick up the chnages and pick the classed which you want to instrument.

How to apply filters in Purify plus / coverage : 
License issues in the Purify plus :


0 comments to "Rational purify coverage for J2EE application deployed in Websphere"

Post a Comment

Who ever writes Inappropriate/Vulgar comments to context, generally want to be anonymous …So I hope U r not the one like that?
For lazy logs u can at least use Name/URL option which don’t even require any sign-in, good thing is that it can accept your lovely nick name also and URL is not mandatory too.
Thanks for your patience
~Krishna(I love "Transparency")
వీలయితే నాల్గు పోస్టులు ...కుదురితే ఒక కామెంటూ ...

Translate

Enter your email address:

Buffs ...

Visitors


hits counter
View My StatsCheck Google Page Rank

Add to Google Reader or Homepage

Bookmark and Share

Tags


Powered by WidgetsForFree