Labels

Thursday, August 30, 2012

JAVA/JEE Interview Tips ?

#1

Be honest to answer technical questions as you are not expected to remember everything (for example you might know a few design patterns but not all of them). If you have not used a design pattern in question, request the interviewer, if you could describe a different design pattern. You have no control over what questions get asked, but you have control over what message you want to get across to the interviewer. This is done mainly through open-ended questions like

Tell us about a instance in your recent project where you made a significant contribution, where you had to choose from different available options, also give us the reason how and why you chose the particular option?


More open-ended questions are discussed in Tip#4. So, make the most of your open-ended interview questions through proper preparation. Research the organization, review the requirements, review your resume, evaluate   how you can link your achievements and experience to the requirements, and have a list of questions for the interviewer (interviews are two way street -- you need to assess the organization as well  -- this will make your dilemma easier if you get multiple job offers ).

 #2

Every body is nervous for interviews and being a little nervous is natural. But if you are too nervous then you can overcome this by preparing for your interviews and by treating each interview as a free technical/behavioural training course. Have an attitude that even if you are not going to get the job, you are going to learn something good out of it. If you go with this attitude you will put yourself in a win/win situation and you might really get the offer. If you take this attitude you can learn a lot from your interviews. Also never think that you have to answer all the questions correctly. Do not get put off by a tricky or a difficult question. What really earns you a job is the combination of your knowledge + experience + soft skills + attitude

 #3

Where possible briefly demonstrate how you applied your skills/knowledge in the key areas like design concepts, transactional issues, performance issues, memory leaks, best practices etc along with your business skills and interpersonal skills. Find the right time to raise questions and answer those questions to show your strength in the technical key areas, business and interpersonal skills.

 #4

Tell me about yourself or about some of the recent projects you have worked with? What do you consider your most significant achievement? Why do you think you are qualified for this position?

Above mentioned interview questions are very common and the interviewer will be mainly looking for 4 qualities:

1. Passion.
2. Ability to understand potential failures (transactional issues, concurrency issues, design issues etc).
3. Ability to see things at a high level as well as drill down when required.
4. Ability to think dynamically to deliver solutions to complex problems and ability to analyse “what if ” scenarios (What if I want to support a non Web client?, What if I want to support other types of products? etc).

 #5

What was the last Java related technical book or article you read? Which Java related website(s) or resource(s) do you use to keep your knowledge up to date beyond Google? What do you think of some of the emerging technologies/frameworks like AOP, IOC, Spring, Tapestry etc? What recent technology trends are important to enterprise development? 

Tuesday, August 21, 2012

What are the default port numbers for servers?

Step by step Tomcat with Apache Integration on Linux server ?

# Installing and configuring mod_jk

To make connection between Tomcat and Apache, you will need to download and install mod_jk connector.

I chose to download the current source from the Apache archives:- http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/

[root@map007 /]# cd /usr/local

[root@map007 local]# wget http://archive.apache.org/dist/jakarta/tomcat-connectors/jk/source/jk-1.2.15/jakarta-tomcat-connectors-1.2.15-src.tar.gz

[root@map007 local]# tar -zxvf jakarta-tomcat-connectors-1.2.15-src.tar.gz

Change to the /usr/local/jakarta-tomcat-connectors-1.2.15-src/jk/native directory.

[root@map007 local]# cd jakarta-tomcat-connectors-1.2.15-src/jk/native

Now you are ready to create the custom configure file for your system. Execute the following:

[root@map007 local]# ./buildconf.sh

[root@map007 local]# ./configure –with-apxs=/usr/bin/apxs2

Now build the mod_jk with the following:

[root@map007 local]# make

Finally, if you were successful with the previous commands, copy the newly created mod_jk.soto your Apache2 modules directory. My modules were located at /usr/lib/apache2/modules.

[root@map007 /]# cp /usr/src/jakarta-tomcat-connectors-1.2.15-src/jk/native/apache-2.0/mod_jk.so /usr/lib/apache2/modules
 # Configuring Tomcat and Apache

[root@map007 /]# vi /etc/apache2/workers.properties

workers.tomcat_home=/usr/lib/apache-tomcat

workers.java_home=/usr/lib/jdk

ps=/

worker.list=worker1

worker.default.port=8009

worker.default.host=localhost

worker.default.type=ajp13

worker.default.lbfactor=1

  # Save and close the file.

# Now you have to configure httpd.conf file and following lines.

[root@map007 /]# vi /etc/apache2/httpd.conf

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

# Where to find workers.properties

JkWorkersFile /etc/apache2/workers.properties

# Where to put jk logs

JkLogFile /var/log/apache2/mod_jk.log

# Set the jk log level [debug/error/info]

JkLogLevel info

# Select the log format

JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

Save and close the file.

Now a final security point.

[root@map007 /]# chown -R tomcat:tomcat /usr/lib/apache-tomcat-5.5.16

# Now restart the Tomcat.

[root@map007 /]# cd /usr/local/tomcat/bin

[root@map007 bin]# ./shutdown.sh

[root@map007 bin]# ./startup.sh

And restart Apache:

[root@map007 /]# /etc/init.d/apache2 restart

You have Done all the Configurations.

Note :- Start Tomcat first: Always start Tomcat first and then start Apache.
References and paths:

Tomcat conf:

/usr/lib/apache-tomcat/conf/server.xml

Apache modules:

/usr/lib/apache2/modules

Apache conf:

/etc/apache2/workers.properties

/etc/apache2/httpd.conf

Tomcat stop and start:

cd /usr/local/apache-tomcat/bin

./shutdown.sh

./startup.sh

Apache2:

/etc/init.d/apache2 restart

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

Step by step Installation Tomcat on Linux ?

Download and Install JAVA

Download j2sdk-<version> from Sun Download center http://developers.sun.com/downloads/


# chmod +x j2sdk-1_4_2_09-linux-i586.bin

# ./j2sdk-1_4_2_09-linux-i586.bin

Now set java home path

# vi .bash_profile

JAVA_HOME=/usr/local/j2sdk

Now Check if Java is installed on the server using command java -version

[root@map ~]# java -version

java version “1.6.0_07?

Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)

# Download Tomcat

Now Download Tomcat from Apache Website and extract it

http://tomcat.apache.org/download-55.cgi

# cd /usr/local/

#wget http://www.poolsaboveground.com/apache/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.tar.gz

# tar -zxvf apache-tomcat-6.0.18.tar.gz

Create Symlink for the Tomcat Folder

# ln -s /usr/local/apache-tomcat-6.0.18 /usr/local/apache/tomcat

# Install Tomcat

# cd apache-tomcat-6.0.18

# cd bin

# tar xvfz jsvc.tar.gz

# cd jsvc-src

# chmod +x configure

# ./configure

# make

# cp jsvc ..

# cd ..

Now set Cataline home path


# vi .bash_profile

CATALINA_HOME=/usr/loca/tomcat

JAVA=/usr/loca/j2sdk/bin

Save and exit

# Type following commands

# export JAVA_HOME=/usr/local/j2sdk

# export JAVA=/usr/local/j2sdk/bin

# export CATALINA=/usr/local/tomcat

# Start Tomcat

Use Following script to start Tomcat Service on the Server

# /usr/local/apache/tomcat/bin/startup.sh

# Running Tomcat as non root user

Due to security reasons always run tomcat as non-root user i.e. tomcat. To run it as tomcat first you will have to change the ownership of the tomcat folder

# chown -R tomcat.tomcat /usr/local/apache-tomcat-6.0.18

Now Tomcat can be stopped and started under user tomcat using following commands:

# su -l tomcat -c /usr/local/apache/tomcat/bin/startup.sh

# su -l tomcat -c /usr/local/apache/tomcat/bin/shutdown.sh

# Test Tomcat installation

open a browser and browse website http://xx.xx.xx.xx:8080 where xx.xx.xx.xx will be your Server IP and If you get Tomcat page than Tomcat has been installed properly on the Server.

# Creating Script to start, stop and restart Tomcat

The above installation step will not create tomcat service so that user can restart tomcat using command service tomcat restart. Create a new file in /etc/init.d as tomcat and copy following contenents into it.

# vi /etc/init.d/tomcat

#!/bin/bash

#

# Startup script for Tomcat

#

# chkconfig: 345 84 16

# description: Tomcat jakarta JSP server

# Necessary environment variables

export CATALINA_HOME=”/usr/local/tomcat”

if [ ! -f $CATALINA_HOME/bin/catalina.sh ]

then

echo “Tomcat not available…”

exit

fi

start() {

echo -n -e ‘\E[0;0m'"\033[1;32mStarting Tomcat: \033[0m \n"

su -l tomcat -c $CATALINA_HOME/bin/startup.sh

echo

touch /var/lock/subsys/tomcatd

sleep 3

}

stop() {

echo -n -e '\E[0;0m'"\033[1;31mShutting down Tomcat: \033[m \n"

su -l tomcat -c $CATALINA_HOME/bin/shutdown.sh

rm -f /var/lock/subsys/tomcatd

echo

}

status() {

ps ax --width=1000 | grep "[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’ | wc | awk ‘{print $2}’ > /tmp/tomcat_process_count.txt

read line < /tmp/tomcat_process_count.txt

if [ $line -gt 0 ]; then

echo -n “tomcatd ( pid ”

ps ax –width=1000 | grep “[o]rg.apache.catalina.startup.Bootstrap start” | awk ‘{printf $1 ” “}’

echo -n “) is running…”

echo

else

echo “Tomcat is stopped”

fi

}

case “$1? in

start)

start

;;

stop)

stop

;;

restart)

stop

sleep 3

start

;;

status)

status

;;

*)

echo “Usage: tomcatd {start|stop|restart|status}”

exit 1

esac

Now save and exit from the file. Now assign executable permission to this file

# chown 755 /etc/init.d/tomcat

Enable it for all the Run-levels

# chkconfig –add tomcat

# chkconfig tomcat on

Now you can restart tomcat service using following commands.

# service tomcat restart <<< To restart tomcat

# service tomcat stop <<< To stop Tomcat

# service tomcat start <<< To start Tomcat

# service tomcat Status <<< to check the status of Tomcat

Now you have successfully installed Tomcat.

Daily use weblogic admin Linux Commands ?

To view System Resource Information

uname --help

uname -r

grep model /proc/cpuinfo

grep MemFree /proc/meminfo

sudo -u root lastcomm -f /var/account/pacct

cat /proc/version

# cat /proc/cpuinfo

# cat /proc/meminfo

# cat /proc/zoneinfo

# cat /proc/mounts

cat /etc/redhat-release

grep MemTotal /proc/meminfo

grep SwapTotal /proc/meminfo

df -k /tmp

grep "model name" /proc/cpuinfo

ifconfig (/sbin/ifconfig)

uaname -r

lshal:detected hardware

rpm -qa:  display pakage

rpm -qa | less

Linux Kernel Information:


cat /etc/sysctl.conf

cat /etc/hosts

/sbin/ifconfig

Uname -r

cat /etc/security/limits.conf

cat /proc/sys/kernel/sem

cat /proc/sys/kernel/shmmax

cat /proc/sys/kernel/shmall

cat /proc/sys/kernel/shmmni

cat /proc/sys/fs/file-max

cat /proc/sys/net/ipv4/ip_local_port_range

/sbin/lsmod

cat /etc/issue

sysctl -a | grep shm

sysctl -a | grep ip_local_port_range

/etc/inittab:  init process determines which runlevel it should be

w, ps -a, ps -Alf, ps -AlFH, ps -AlLm

ps -u oracle, ps -u anguyen

Commands to monitor bottlenecks such as Disk, Memory / CPU/Network, or System Activity:

top ? t, m, A: top consumer, r: renice, o: interactively select

vmstat 3, vmstat -m:memority slab info, vmstat -a

w, ps -a, ps -Alf, ps -AlFH, ps -AlLm

ps -u oracle, ps -u attunity

uptime

free

fee -s 2

watch -n 3 -d free

watch -d cat /proc/meminfo

sar -B -f /var/log/sa/sa14

sar -W -f /var/log/sa/sa14

vmstat -m

vmstat -a

ipcs -sm

ipcs -lms

sar -n DEV | more

sar 4 5

mpstat -P ALL

MEMORY intensive process:

ps -e -o pmem,pid,user,tty,args | grep -i oracle | sort -n -k 1 -r | head

watch -n 3 -d free

watch -d cat /proc/meminfo

CPU intensive process

top

ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head

mpstat -P 0 2 20 (processor 0

mpstat -P ALL

sar -u -f

Disk Storage
************************************

iostat -d 3, iostat 2 15

iostat -xd 10


sorting files by size
***********************

ls -alS | head -5

mpstat -P ALL

sar 4 5

****************************************************
Network
**************************************************

lsmod | grep -i bonding

cat /etc/sysconfig/network-scripts/ifcfg-eth0 (check bonding)..the difference NETWORK, IPADDRESS, NETMASK

netstat -s | less

netstat --interfaces eth0

netstat -ptc

sar -n DEV

netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq

tcpdump -n -i eth1 -s 0 -w output.txt src or dst port 80

iptraf - Real-time Network Statistics

Network traffic

netstat -ptc

sar -n DEV

sar - Collect and Report System Activity

*************************************************
Oracle
***************************************************

cpio -idmv < 10201_database_linux_x86_64.cpio

id oracle

id nobody

pgrep sshd

env | grep PATH

detected hardware lshal:

init process determines which runlevel it should be /etc/inittab

shutdown

shutdown -t3 -r now

mount /dev/hda4 /data/oracle/bkup1:

 grep ‘Ashley Nguyen’ /etc/passwd

find / -name install.log

sed ‘s/anguyen/lvu/’ /etc/passwd > /tmp/test

ps aux | grep nfs

free:

Ifconfig -a

To determine the amount of shared memory available, enter the following command:automatic memory management


# df -k /dev/shm/

To determine the distribution and version of Linux installed, enter the following command:

# cat /proc/version

To determine whether the required packages are installed, enter commands similar to the following:

# rpm -q package_name

Add group

# /usr/sbin/groupadd oper

Modify user:  usermod -g oinstall -G dba oracle

Create disks:

fdisk -l

give password to oracle user

passwd oracle

change ownership in linux

chown

clear screen

clear

TAR - backup / restore

tar -cf myfiles.tar *.trc (create)

tar xvf myfiles.tar (extract)

tar tvf myfiles.tar (show the details)

Steps to check Apache connection and error log ?

Below is the details.

date;netstat -ant | grep 80 | grep TIME_WAIT | wc -l

cat /etc/httpd/conf/httpd.conf | grep MaxClients

head /var/log/httpd/error_log

Apache Server Interview Questions and Answers for Linux adminisration?


Q: - What is location of log files for Apache server ?
/var/log/httpd
Q: - What are the types of virtual hosts ?

name-based and IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.
Q: - How to restart Apache web server ?

service httpd restart
Q: - How to check the version of Apache server ?

rpm -qa |grep httpd
Q: - What is meaning of "Listen" in httpd.conf file ?

Port number on which to listen for nonsecure (http) transfers.
Q: - What is DocumentRoot ?

it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
Q: - On which port Apache server works ?

http - port 80
https - port 443
Q: - Tell me name of main configuration file of Apache server ?

httpd.conf
Q: - On which version of apache you have worked ?

httpd-2.2.3
Q: - What do you mean by a valid ServerName directive?

The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.
Q: - What is the main difference between <Location> and <Directory> sections?

Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page
What is the difference between a restart and a graceful restart of a web server?

During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration.
Q: - What is the use of mod_perl module?

mod_perl scripting module to allow better Perl script performance and easy integration with the Web server.
Q: - If you have added “loglevel Debug” in httpd.conf file, than what will happen?

 It will give you more information in the error log in order to debug a problem.
Q: - Can you record the MAC (hardware) address of clients that access your server.

No
Q: - Can you record all the cookies sent to your server by clients in Web Server logs?

Yes, add following lines in httpd.conf file.

CustomLog logs/cookies_in.log "%{UNIQUE_ID}e %{Cookie}i" CustomLog logs/cookies2_in.log "%{UNIQUE_ID}e %{Cookie2}i"
Q: - Can we do automatically roll over the Apache logs at specific times without having to shut down and restart the server?

Yes
Use CustomLog and the rotatelogs programs

Add following line in httpd.conf file. CustomLog "| /path/to/rotatelogs/path/to/logs/access_log.%Y-%m-%d 86400" combined
Q: - What we can do to find out how people are reaching your site?

Add the following effector to your activity log format. %{Referer}
Q: - If you have only one IP address, but you want to host two web sites on your server. What will you do?
In this case I will use Name Based Virtual hosting.
ServerName 10.111.203.25
NameVirtualHost *:80
<VirtualHost *:80>
ServerName web1.test.com
DocumentRoot /var/www/html/web1
</VirtualHost>

<VirtualHost *:80>
ServerName web2.test2.com
DocumentRoot /var/www/html/web2
</VirtualHost>
Q: - Can I serve content out of a directory other than the DocumentRootdirectory?


Yes, by using “Alias” we can do this.
Q: - If you have to more than one URL map to the same directory but you don't have multiple Alias directives. What you will do?

In this case I will use “AliasMatch” directives.

The AliasMatch directive allows you to use regular expressions to match arbitrary patterns in URLs and map anything matching the pattern to the desired URL.
Q: - How you will put a limit on uploads on your web server?

This can be achieved by LimitRequestBody directive.
<Directory "/var/www/html/data_uploads">
LimitRequestBody 100000
</Directory>
Here I have put limit of 100000 Bytes
Q: - I want to stop people using my site by Proxy server. Is it possible?


<Directory proxy:http://www.test.com/myfiles>
Order Allow,Deny
Deny from all
Satisfy All
</Directory>
Q: - What is mod_evasive module?

mod_evasive is a third-party module that performs one simple task, and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack, and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time, and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.
Q: - How t to enable PHP scripts on your server?

If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php
Q: - Which tool you have used for Apache benchmarking?

ab (Apache bench)
ab -n 1000 -c 10 http://www.test.com/test.html
Q: - Can we cache files which are viewed frequently?

Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html
Q: - Can we have two apache servers having diff versions?
Yes, you can have two different apache servers on one server, but they can't listen to the same port at the same time.Normally apache listens to port 80 which is the default HTTP port. The second apache version should listen to another port with the Listen option in httpd.conf, for example to port 81.

For testing a new apache version before moving your sites from one version to another, this might be a good option.You just type www.example.com:81 in the browser window and you will be connected to the second apache instance.

Steps to start and stop apache server in linux

you need to type the following command to start the apache server

$>service httpd start

or

$>/etc/init.d/httpd start

To stop the server

$>service httpd stop

or

$>/etc/init.d/httpd stop

Wednesday, August 15, 2012

what is Work Managers in Weblogic Server?

Work Managers:

WebLogic Server is self-tuning in nature by default, that is, it adjusts the thread size as needed.
WebLogic Server uses a single thread pool whose size changes automatically to maximize throughput. This process is called server self-tuning. The queue monitors throughput over time and based on history and determines whether to adjust the thread count. The server increases or decreases pool size if a higher or lower thread count increases performance. All the work is executed within this pool.
WebLogic Server prioritizes work based on rules defined by an administrator and run-time metrics, including the actual time it takes to execute a request and the rate at which requests are entering and leaving the pool. This new strategy makes it easier for administrators to allocate processing resources and manage performance, avoiding the effort and complexity involved in configuring, monitoring, and tuning custom executes queues.

Default Work Manager:

•  All applications are given equal priority.
•  A default fair share of threads is given to each application.
•  If no Work Manager is explicitly assigned to an application, it uses the default Work Manager.
•  The default Work Manager can be overridden by creating and configuring a global Work Manager called default.
Work Manager Scheduling Guidelines:
•  Use when the default fair share is insufficient.
•  Use to schedule work based on application priority.
•  Use when applications require different response times.
•  Use to avoid server deadlocks.

Components of Work Manager:

–  Request Classes.
–  Constraints.
Request Classes:
Request classes help schedule work based on priority.
Three types of request classes:
•  fair-share-request-class
•  response-time-request-class
•  context-request-class
Fair Share Request Class:
The fair share request class specifies the average percentage of thread-use time required to process requests.
•  Configuration options: Name and Fair share value
•  Default value: 50
•  Minimum value: 1
•  Maximum value: 1000
Fair Share Request Class
The fair share request class specifies the average percentage of thread-use time required to process requests.
Snippet: high priority fair share request class
fair-share-request-class>
<name>high_priority</name>
<fair-share>90</fair-share>
</fair-share-request-class>

Snippet: low priority fair share request class
<fair-share-request-class>
<name>low_priority</name>
<fair-share>10</fair-share>
</fair-share-request-class>

Response Time Request Class:
The response time request class specifies a response time goal in milliseconds.
•  Configuration options: Name and Goal (milliseconds)
•  Default value: 0
Snippet: fast response request class <ModuleA>
<response-time-request-class>
<name>fast_response_time</name>
<goal-ms>1000</goal-ms>
</response-time-request-class>
Snippet: slow response request class <ModuleB>
<response-time-request-class>
<name>slow_response_time</name>
<goal-ms>8000</goal-ms>
</response-time-request-class>
Context Request Class:
The context request class assigns request classes to requests based on context information, such as the current user or the current user’s group.
•Configuration options: Name and context case
Snippet: context request class
<context-request-class>
<name>simple_context</name>
<context-case>
<user-name>system</user-name>
<request-class-name>high_fairshare</request-class-name>
</context-case>
<context-case>
<group-name>everyone</group-name>
<request-class-name>low_fairshare</request-class-name>
</context-case>
</context-request-class>
Constraints:
•  A constraint defines:
–  The minimum and maximum numbers of threads allocated to execute requests
–  The total number of requests that can be queued or executing before WebLogic Server begins rejecting requests
Types of constraints:
–  max-threads-constraint
–  min-threads-constraint
–  capacity.
Maximum Threads Constraints:
The maximum threads constraint limits the number of concurrent threads that can execute requests sharing this constraint.
Configuration options:
–  Name: The user-specified name
–  Count: Thread count (Default value: -1)
– Data Source: The name of the connection pool whose size is taken as the maximum constraint
Snippet: maximum threads constraint
<max-threads-constraint>
<name>max_threads</name>
<count>10</count>
<connection-pool-name></connection-pool-name>
</max-threads-constraint>
Minimum Threads Constraints:
The minimum threads constraint guarantees a minimum number of concurrent threads that the server allocates to requests sharing this constraint.
Configuration options:
–  Name: The user-specified name.
–  Count: Thread count (Default value: -1)
Snippet: minimum threads constraint
<min-threads-constraint>
<name>min_threads</name>
<count>1</count>
</min-threads-constraint>
Capacity Constraints:
The capacity constraint causes the server to reject requests only when it has reached its capacity to avoid server deadlocks.
Configuration options:
–  Name: The user-specified name
–  Count: Thread count (Default value: -1)
Snippet: capacity constraint
<capacity-constraint>
<name>my_capacity</name>
<count>50</count>
</capacity-constraint>
Referencing Classes or Constraints:
A Work Manager is defined by encapsulating one request class and/or one constraint to schedule requests.
Configuration options:
–  Name and request class/constraint
Snippet: Work Manager
<work-manager>
<name>priority_work_manager</name>
<fair-share-request-class>
<name>very_high_priority</name>
<fair-share>1000</fair-share>
</fair-share-request-class>
<min-threads-constraint>
<name>min_five_Threads</name>
<count>5</count>
<min-threads-constraint>
</work-manager>

How to Create and configuring Work Managers in WebLogic?

A Work Manager defines a set of request classes and thread constraints that manage work performed by WebLogic Servers. This page displays the global Work Managers, request classes and thread constraints defined for this domain.
Global Work Managers are defined at the domain level. You can also define application-level and module-level Work Managers.

Create a Global Work Manager

Using the Administration Console, you can create global work managers that are used to prioritize thread execution.
Note: You cannot create or configure app-scoped Work Managers using the Administration Console.
Follow these steps to create a global Work Manager:
1). If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit
2). In the Administration Console, expand Environment and select Work Managers.
3). Click New.
4). Select the Work Manager button, then click Next.
5). Enter a name for the new Work Manager.
6). Click Finish.
7). To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
Not all changes take effect immediately—some require a restart
After you finish
After you have created a global Work Manager, you must create at least one request class or constraint. The global Work Manager uses request classes and constraints to determine how to priortize work.

Create a Global Request Class

To create a global request class:
1). If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit
2). In the Administration Console, expand Environment and select Work Managers.
3). Click New.
4). Select the button next to the type of global request class you want to create.
5). Click Next.
6). Input the configuration information based upon the type of request class you are creating.
7). Click Finish.
8). To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
Not all changes take effect immediately—some require a restart
Result
The new constraint appears in the Global Work Managers, Request Classes and Constraints table.
After you finish
After you have created a request class, you must assign it to a Work Manager in order to use it. Each Work Manager can contain only one request class of each type, but you can share request classes among multiple Work Managers.

Create a Global Constraint

To create a global constraint:
1). If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit
2). In the Administration Console, expand Environment and select Work Managers.
3). Click New.
4). Select the button next to the type of global constraint you want to create.
5). Click Next.
6). Input the configuration information based upon the type of constraint you are creating.
7). Click Finish.
8). To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
Not all changes take effect immediately—some require a restart
Result
The new constraint appears in the Global Work Managers, Request Classes and Constraints table.
After you finish
After you have created a constraint, you must assign it to a Work Manager in order to use it. Each Work Manager can contain only one constraint of each type, but you can share constraints among multiple Work Managers.

Delete a Global Work Manager, Constraint, or Request Class

To delete a global Work Manager:
1). If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit
2). In the Administration Console, expand Environment and select Work Managers.
3). Select the check box next to the Work Manager, request class, or constraint you want to delete.
4). Click Yes to confirm that you want to delete the selected item.
5). To activate these changes, in the Change Center of the Administration Console, click
ActivateChanges.
Not all changes take effect immediately—some require a restart

Solution for Unable To Start Admin Server with Error BEA-000386

Symptoms
After an outage or unexpected physical machine shutdown weblogic does not start.
If you see this error when admin server is starting, or the following exception is thrown:
<Critical><BEA-000386> <Server subsystem failed. Reason: java.lang.AssertionError: java.lang.reflect.InvocationTargetException
java.lang.AssertionError: java.lang.reflect.InvocationTargetException
at weblogic.descriptor.DescriptorManager$SecurityServiceImpl$SecurityProxy._invokeServiceMethod(DescriptorManager.java:175)

Changes
No changes, in particuluar. Possibly a physical machine shutdown or outage.
Reason:
The file SerializedSystemIni.dat has become corrupted. This file contains the hash to decrypt the encrypted credential values if the config.xml. So, the Admin Server will not start because is not able to decrypt the credential and perform authentication properly.
ReSolution:
The corrupted hash values must be replaced.
1. Edit all the encrypted values in the config.xml to plain text.
Example:
Before:
<credential-encrypted>{AES}b3I7UhWtRyj4DuKMIDVtW4Ln2nzH+HiYRhhQw1H2qpU0qJMOaDlK8iFZ+LvlJu+i
Zs6pptFJgWz8ryyudL1Zyvf00Rg11z9Iib7hoDC8covMFuig8wx7iOGK88zeKH7U</credential-encrypted>
After:
<credential-encrypted>MyCredentialInPlainText</credential-encrypted>
2. Restart the Admin Server.
After restart the Admin Server, the credentials will be encrypted again and the AdminServer will start.

How can we Passwords Are Protected in WebLogic Server?

It is important to protect passwords that are used to access resources in a WebLogic domain. In the past, usernames and passwords were stored in clear text in a WebLogic security realm. Now all the passwords in a WebLogic domain are hashed. The SerializedSystemIni.dat file contains the hashes for the passwords. It is associated with a specific WebLogic domain so it cannot be moved from domain to domain.
If the SerializedSystemIni.dat file is destroyed or corrupted, you must reconfigure the WebLogic domain. Therefore, you should take the following precautions:
Make a backup copy of the
  • SerializedSystemIni.dat file and put it in a safe location.
  • Set permissions on the SerializedSystemIni.dat file such that the system administrator of a WebLogic Server deployment has write and read privileges and no other users have any privileges.

What are the Deployment tips in Weblogic server?

WebLogic Server allows you to store deployment units either as a single archive file, or as an exploded directory that contains the same contents of the archive file.

An archive file is a single file that contains all of an application’s or module’s classes, static files, directories, and deployment descriptor files.

Deploy user applications on managed server instances. This separates the administration application (console) and the domain configurations from user applications.

Avoid using automatic deployment of applications in production and multiple-server environments. Running the WebLogic domain in “Production Mode” will disable the automatic deployment in production. If you create scripts for deploying applications as a part of an overall build, consider using the wldeploy Ant task.

If you deploy an application (or module) with the On Future Redeploys option set to Ignore Roles and Policies From DD one or more times before setting it to Initialize Roles and Policies From DD, you can set security policies and security roles using the admin console. But these changes using admin console will override security specified in deployment descriptors.

Tips:

    Use production mode to run production applications.

    Avoid deploying user applications on admin server instance.

    To specify the server’s default Web application, use an empty context-root element or an element with a value “/” in the weblogic.xml or application.xml file.

    Changing security policies for an application after deployment in the admin console overrides the policies in the deployment descriptor.

Redeployment:

Once you deploy an application, you can redeploy the application itself or selected parts of the application. Redeploying an entire application involves unloading all its classes and then deploying the application again with the changed files. Redeploying an application in production is a serious undertaking that can affect performance, so plan application updates carefully.

If a Web application is in production and in use, redeploying causes WebLogic Server to lose all active HTTP sessions. HTTP session can be restore by turning a special property ON in the WebLogic specific deployment descriptor file (weblogic.xml).

Tips:

    If you have modified only static files, it is possible to refresh them without redeploying the entire application.

    Use command-line option to partially redeploy an expanded application (weblogic.Deployer … -redeploy …).

    For changing deployment parameters without changing the application, use alternate deployment descriptors.

    To simplify re-distributing application archives to multiple WebLogic Server instances during redeployment use stage mode deployment.

    A managed server with all application staged can be started and be made fully functional in independence mode if admin server is not available.

Enterprise Application:

WebLogic optimizes EJB access, if the client is within the same enterprise application classes and libraries can be shared across all archive applications within the enterprise application. So consider creating enterprise archives rather than deploying related applications independently.

Also Enterprise-wide settings can be used, rather than multiple local settings in deployment descriptors. Create JDBC resources in the WebLogic Server domain, using the WebLogic console, rather than employing the weblogic-application.xml technique.

Tips:

    Avoid deploying EJB archives and related Web applications as separate independent applications in WebLogic Server.

    Improved runtime performance can be achieved when Web components access EJB components within the same enterprise application.

    The enterprise can be deployed as one deployment unit.

    Do not place application-specific classes or JAR files in the system classpath (to avoid having to restart the server for reloading them).

    When using WebLogic Server 8.1, use the new APP-INF/lib and APP-INF/classes directories in the enterprise-application directory structure, to simplify the packaging of utility classes and utility archives.

Pre-compilation:

Production and test deployments should include precompiled JSP pages and EJBs (use weblogic.appc or weblogic.jspc/weblogic.ejbc with earlier weblogic versions). They can catch compile-time errors in applications long before you deploy them. Also offline compilation validates the deployment descriptors for compliance with current specifications.

Deploying compiled applications reduces deployment time and subsequent server restart time. Development deployments intended for use on the developer’s workstation can use on-the-fly compilation.

Tips:

    To precompile JSP files during application deployment or server startup, enable the precompile parameter in weblogic.jar.

    To disable pagecheck and recompilation at runtime in a production environment, set pageCheckSeconds to -1.

    You can use weblogic.appc or weblogic.ejbc (deprecated) to compile EJBs outside the server VM. This reduces the subsequent server restart time.

    Use the weblogic.Deployer utility, or its associated Ant task, wldeploy, in scripts to automate deployment in production environments.

Deployment Descriptor Editing:

Changing the deployment descriptor of a J2EE application takes effect only when the application is redeployed. The WebLogic admin console provides a way to change some deployment descriptor attributes without redeploying the application. To take advantage of this feature, you must to deploy the application in exploded directory structure (non-archived format), when the domain is running in development mode.

To change descriptor values of the application after deployment (as exploded format) go to Web Application Module > Your Application > Configuration tab > Descriptor tab.

Tips:

    Use tools provided with WebLogic Server to generate and edit XML deployment descriptors.

    WebLogic Builder generates descriptors; it includes an interface for editing descriptors.

    DDInit is a command-line utility for generating deployment descriptors for WebLogic Server applications.

    ddcreate is an Ant task that can be used for creating deployment descriptors for enterprise applications.

EJB:

A stateless session EJB free pool improves performance and throughput as beans are created at server startup or deployment time. WebLogic Server uses a cache of bean instances to improve the performance of stateful session EJBs. The cache stores active EJB instances in memory so that they are immediately available for client requests.

Using application-level/combined cache will result in reduced fragmentation, better utilization of memory and heap space. But the use of application-level/combined cache is limited to entity EJBs in an enterprise application. For an application that requires high throughput, use bean-level caching. Bean-level caching is effective because tasks do not compete for control of the one thread of control in a combined cache.

To make use of WebLogic provided optimization of calls made to EJB components within an application, set to true.

The same can also be achieved by writing local interfaces for EJBs for access within the same enterprise application.

Concurrency strategies for entity EJBs include:

Database:

Improves throughput by deferring to database (for EJB 1.1 and 2.0, this is the default and recommended mechanism)

Exclusive:

Avoids deadlocks; use it only if a high level of consistency is required on non-clustered servers

Optimistic:

No lock will be held in the EJB container or database during transaction. But the EJB container ensures that the data being updated by a transaction has not been changed.

Read-only:

Container does not attempt to save a bean’s state at the end of a transaction; use this for EJBs that do not make any change to persistent data. With the read-only strategy, use to invalidate cached bean data in the container; this updates the data from the persistent store when a timeout occurs.

Tips:

    Consider the number of execute threads, to configure maximum number of beans in the free pool.

    To limit the memory used by a stateful session EJB, set the maximum number of beans that can reside in the cache (max-beans-in-cache).

    Too small cache causes frequent activation and passivation.

    Too large a cache wastes memory.

    LRU algorithm keeps a bean in the passive state after it passes the ideal number timeout seconds.

    To avoid the associated overhead of passivating stateful session EJBs, use the not recently used (NRU) algorithm

    Local interfaces for EJBs provide optimized access for server-side EJB clients.

    Combined cache enables the administrator to tune just one cache, rather than multiple caches, in weblogic-application.xml.

    Message-driven beans that use container-managed transactions must use XA connection factories.

Steps to Change The “Weblogic” User Password ?

The weblogic user’s password can be changed by following these steps:

  1. Login to WebLogic admin server console. e.g. http://localhost:7001/console
  2. Under Domain Structure, select “Security Realms”.
  3. Click on “myrealm”. This is the default realm.
  4. Click on the tab for “Users and Groups.”
  5. Click on the weblogic user.
  6. Click on the Passwords tab. Update the password and save it.
Note:
Once the weblogic user’s password is changed, the same needs to be updated in the boot.properties file under :
/user_projects/domains/servers/AdminServer/security

Why WebLogic Server hangs while writing JTA logs?

WebLogic Server hangs while writing JTA logs. The client software cannot connect to WLS. There is no error in the application log. We collected a thread dump (kill -3) of the server java process and found the following key messages:
“ExecuteThread: ’5′ for queue: ‘weblogic.kernel.Default’”:
waiting to lock monitor 01c96328 (object 2e4cdbf0, a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer),
which is held by “ExecuteThread: ’17′ for queue: ‘weblogic.kernel.Default’”
“ExecuteThread: ’17′ for queue: ‘weblogic.kernel.Default’”:
waiting to lock monitor 01c96528 (object 2e4cdc08, a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer),
which is held by “ExecuteThread: ’5′ for queue: ‘weblogic.kernel.Default’”
JTA has transaction exceptions and is busy writing them to the JTA log and the server stops responding.
“ExecuteThread: ’5′ for queue: ‘weblogic.kernel.Default’”:
at weblogic.transaction.internal.TransactionLoggerImpl$LogDisk.release(TransactionLoggerImpl.java:1324)
- waiting to lock (a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer)
- locked (a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer)
at weblogic.transaction.internal.TransactionLoggerImpl.release(TransactionLoggerImpl.java:389)
at weblogic.transaction.internal.ServerTransactionImpl.releaseLog(ServerTransactionImpl.java:2767)
at weblogic.transaction.internal.ServerTransactionManagerImpl.remove(ServerTransactionManagerImpl.java:1466)
at weblogic.transaction.internal.ServerTransactionImpl.setRolledBack(ServerTransactionImpl.java:2597)
at weblogic.transaction.internal.ServerTransactionImpl.globalRetryRollback(ServerTransactionImpl.java:2816)
at weblogic.transaction.internal.ServerTransactionImpl.globalRollback(ServerTransactionImpl.java:2576)
at weblogic.transaction.internal.ServerTransactionImpl.internalRollback(ServerTransactionImpl.java:371)
at weblogic.transaction.internal.TransactionManagerImpl$TMXAResource.rollback(TransactionManagerImpl.java:1035)
at weblogic.wtc.gwt.OatmialUnknownXidHandler.execute(WTCService.java:3402)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
“ExecuteThread: ’17′ for queue: ‘weblogic.kernel.Default’”:
at weblogic.transaction.internal.TransactionLoggerImpl$LogDisk.release(TransactionLoggerImpl.java:1323)
- waiting to lock (a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer)
at weblogic.transaction.internal.TransactionLoggerImpl.release(TransactionLoggerImpl.java:389)
at weblogic.wtc.gwt.TuxedoLoggable.onDisk(TuxedoLoggable.java:347)
at weblogic.transaction.internal.TransactionLoggerImpl$LogDisk.write(TransactionLoggerImpl.java:1252)
- locked (a weblogic.transaction.internal.TransactionLoggerImpl$IOBuffer)
- locked (a weblogic.transaction.internal.TransactionLoggerImpl$LogDisk)
at weblogic.transaction.internal.TransactionLoggerImpl.flushLog(TransactionLoggerImpl.java:614)
at weblogic.transaction.internal.TransactionLoggerImpl.store(TransactionLoggerImpl.java:305)
at weblogic.wtc.gwt.OatmialUnknownXidHandler.execute(WTCService.java:3320)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Reason
The problem has occurred due to lack of resources in the server. The server’s resources must be reviewed and tuned for production runtime.
Solution
Following tuning should help to resolve the issue:
  1. Decrease the CheckpointIntervalSeconds.
  2. For WLS 8.1 and prior releases, move the tlogs to a directory where it will not run out of space.
    For 9.x and above, move the default persistence store folder to a place where it will not run out of space.

java.lang.OutOfMemoryError: GC overhead limit exceeded” exception with Sun JDK 1.6

<Error> <Kernel> <BEA-000802> <ExecuteRequest failed 
java.lang.OutOfMemoryError: GC overhead limit exceeded. 
java.lang.OutOfMemoryError: GC overhead limit exceeded 
at java.util.Arrays.copyOfRange(Arrays.java:3209) 
at java.lang.String.<init>(String.java:216) 
at java.lang.StringBuilder.toString(StringBuilder.java:430) 
at weblogic.servlet.internal.ServletRequestImpl.toString(ServletRequestImpl.java:243) 
at java.lang.String.valueOf(String.java:2827) 
Truncated. see log file for complete stacktrace

Cause

The “java.lang.OutOfMemoryError: GC overhead limit exceeded” message means that for some reason the garbage collector is taking an excessive amount of time. 
The parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection or less than 2% of the heap is recovered by garbage collection, an OutOfMemoryError will be thrown.
This feature of throwing  ”GC overhead limit exceeded” message is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small.

Solution

We can avoid the above “java.lang.OutOfMemoryError: GC overhead limit exceeded” exception by disabling the GC overhead limit feature in Sun JDK 1.6 by adding the following argument to the start script of JVM:
-XX:-UseGCOverheadLimit
However, please note that disabling the overhead limit only avoids getting the OutOfMemoryError at an early stage. The OutOfMemoryError is very likely to be thrown at a later stage, because it does not remove the underlying problem. You should still look into your application and JVM settings to find the cause of GC taking an excessively long time.

What is Netstat Command and with examples?

netstat – show network status
DESCRIPTION:
The  netstat  command  displays  the  contents  of   certain network-related  data structures in various formats, depend-ing on the options you select.
 How to view Established connections only?
# netstat -natu | grep ‘ESTABLISHED’
List All Ports (both listening and non listening ports)
List all ports using netstat –a
# netstat –a | more
In order to get the summary statistics for each protocol you would use:
netstat -s | more

List all tcp ports using netstat –at

# netstat –at

List all udp ports using netstat –au

 # netstat –au

List Sockets which are in Listening State

List only listening ports using netstat –l

 # netstat –l

List only listening TCP Ports using netstat –lt

 # netstat –lt

List only listening UDP Ports using netstat –lu

 # netstat –lu

List only the listening UNIX Ports using netstat –lx

 # netstat –lx

Show the statistics for each protocol

Show statistics for all ports using netstat –s

# netstat –s

Show statistics for TCP (or) UDP ports using netstat -st (or) –su

 # netstat -st

# netstat -su

Display PID and program names in netstat output using netstat -p

netstat -p option can be combined with any other netstat option. This will add the “PID/Program Name” to the netstat output. This is very useful while debugging to identify which program is running on a particular port.
# netstat –pt
Don’t resolve host, port and user name in netstat output
When you don’t want the name of the host, port or user to be displayed, use netstat -n option. This will display in numbers, instead of resolving the host name, port name, user name.
This also speeds up the output, as netstat is not performing any look-up.
# netstat -an
If you don’t want only any one of those three items (ports, or hosts, or users) to be resolved, use following commands.

# netsat -a –numeric-ports
# netsat -a –numeric-hosts
# netsat -a –numeric-users
Display Active Connections with Process ID and Program Name
This could be very helpful to identify which program has initiated a specific network connection.
# netstat -tap

Print netstat information continuously

netstat will print information continuously every few seconds.
# netstat –c

Find the non supportive Address families in your system

# netstat –verbose

Display the kernel routing information using netstat -r

# netstat -r
Note: Use netstat -rn to display routes in numeric format without resolving for host-names.
Display the routing cache

 # netstat -rnC

To display all ports open by a process with id PID

 # netstat –aop | grep “56356”

Find out on which port a program is running

 # netstat -ap | grep ssh

Find out which process is using a particular port:

# netstat -an | grep ‘:56356′

How to find out connection count on a particular port using netstat?

 # netstat -ant | grep 56356 | wc –l

# netstat -ant | grep 80 | wc -l
Show the list of network interfaces
# netstat –i
Display extended information on the interfaces (similar to ifconfig) using netstat -ie:
# netstat –ie
How to find the Nature of connections going on my server?
# netstat -ant | awk ‘{print $6}’ | sort | uniq -c | sort -n
How to find the Nature of connections going on my server for a particular port?
# netstat -ant | grep 56356 | awk ‘{print $6}’ | sort | uniq -c | sort –n

Tuesday, August 14, 2012

What is the difference between Websphere Message Broker and Websphere Message Q?

 
WebSphere MQ is a messaging engine that provides assured delivery of some message/payload. MQ provides a Queue Manager: a server application that hosts Queues (to hold messahes) and Channels & Listeners (to allow Queue Managers to communicate with each other). MQ provides an API interface that implements JMS. It also has a number of APIs native to MQ. As of WebSphere MQ version 7.0.1 it also provides a publish-subscribe engine. WebSphere MQ basically lets you put a message in one place and get that message somewhere else with the smallest chance of the message being lost.


WebSphere Message Broker is a program that attempts to provide an any-transport-to-any-transport interface, and an any-language transformation engine. In terms of transports, it provides MQ, JMS (most providers), MQ-FTE, local files, SMPT, FTP/SFTP, HTTP/HTTPS, TCP/TCPSSL, JDBC and probably some other entry hooks I have forgotten. Once the message is in MEssage Broker, you can manipulate that message using ESQL (SQL-like language native to Message Broker), Java, PHP, XSTL. It also contains functionality for message routing, collecting, aggregation, sequencing etc. Message Broker basically allows you to move data from a number of formats (both physical and logical) and manipulate that data before putting it somewhere else, possibly in a different format.

Friday, August 10, 2012

How to Record-Replay JAVA with LoadRunner ?

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…
1
2
3
4
5
6
7
[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.

How to send Emails using Blat utility in LoadRunner

we can send hundreds of emails to the server then one option is to use a web email client to simulate the load but it has following limitations

1. Your own corporate/personal Email id need to be used in LoadRunner Script but it may fill up the mail box

2. Password credentials need to be made visible in the script.

Other option is to use Blat utility which is a third party freeware utility. It sends the contents of a file in an e-mail message using the SMTP protocol.

Download the attached blat.dll utility and create a sample script as shown below.


Action()

{
command_line_Send = (char *)malloc(1024 * sizeof(char));

if(CheckLoadBlatDLL != 0) //if return code not zero then DLL not loaded!!Reload it
{
    lr_output_message("BLAT Emailing DLL Not Loaded Successfully !!! Reloading the DLL");
    CheckLoadBlatDLL = lr_load_dll("blat.dll");
}
f1=fopen(lr_eval_string("C:\\SR_{vuser_id}.txt"), "wb+" );
fprintf(f1,lr_eval_string("Email Performace Testing {TimeStamp}"));
fclose(f1);

//Initialize all the command line parameters for Blat tool

strcpy(DestEmailID,lr_eval_string("{EmailId} ")); // Destination Email ID
strcpy(Subject,lr_eval_string("\"Email PerfTesting{TimeStamp}\" ")); // EmailID Subject
strcpy(SMTPServer,lr_eval_string("{SMTPServer}")); //Your Corporate SMTP Server
strcpy(FromEmailID,lr_eval_string("{FromEmailID} "));// Source Email Id
strcpy(AttachFile,"C:\\attach.pdf "); // Any attachment
strcpy(BodyText,lr_eval_string("C:\\SampleBody{vuser_id}.txt "));// Email Body
lr_output_message("The Destination EmailId is :%s",lr_eval_string("{EmailId}"));

//Verify whether DLL Loaded successfully

if (CheckLoadBlatDLL == 0) //if return code not zero then not DLL not loaded
{
    lr_output_message("BLAT Emailing DLL Loaded Successfully ");
    // Build the Command line for sending Emails
    strcpy( command_line_Send, BodyText);
    // strcat( command_line_Send, "-attach ");
    //strcat( command_line_Send, AttachFile);
    strcat( command_line_Send, "-to ");
    strcat( command_line_Send, DestEmailID);
    strcat( command_line_Send, "-f ");
    strcat( command_line_Send, FromEmailID);
    strcat( command_line_Send, "-s ");
    strcat( command_line_Send, Subject);
    strcat( command_line_Send, "-server ");
    strcat( command_line_Send, SMTPServer);
    lr_output_message("Parameters for Send Command : %s", command_line_Send);
    temp_error_code = Send(command_line_Send);
    lr_output_message("Return code of Send command %d " , temp_error_code);
  //Check successful message sending.
   if (temp_error_code == 0) {
      lr_output_message("Email Sent Successfully ");
   }
  if(temp_error_code != 0){
  switch( temp_error_code ){
  case 1:
   //Command Line Bad Argument
   //Unable to open SMTP socket
   //Command unable to write to socket
   //Server does not like To: address
   // Mail server error accepting message data
   lr_error_message("ERROR : Check the command Line Argument Format");
   break;
  case 2:
   //The server actively denied our connection.
   //The mail server doesn't like the sender name.
   lr_error_message("ERROR : Email Server Denied connection or File does not exist");
   break;
   }//end SWITCH
 }//end IF
}else{
  lr_output_message("Unable to Load the Blat DLL - Check whether DLL exists at the specified location ");
}
free(command_line_Send);
return 0;
}