Sunday, January 12, 2014

Citrix ica client not working in windows 7

I installed Citrix ICA client4.1 in windows7 OS. When i try to connect to remote machine through citrix, it seems unresponsive and takes more time.
But when i press Alt + tab, able to see user inputs are grabbed in remote machine.

Apparently this issue from ica client side, to resolve this edit this windows registry,
set DeferredUpdateMode=false

for Windows 64-bit
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Seamless Windows\

for windows 32-bit
HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Seamless Windows\

restart your windows.

Sunday, December 6, 2009

Search engine framework "compass"

Now a days search in web application brings you good user experience & save time.
Compass is a powerful, transactional Java Search Engine framework. Java bean mostly used in all enterprise application. Compass allow us to map our java bean to underlying search engine, sync data between compass index and datasource[persistence].

The following is the implementation of compass search in core java. Compass supports for some ORM like hibernate, iBatis.

1) Create java project & add compass jar to your lib.

2) Create a bean called ""

public class User {

private Long id;
private String name;
private Integer yearsExperience;
private Float income;

public User() {

public User(Long id, String name, Integer yearsExperience, Float income) { = id; = name;
this.yearsExperience = yearsExperience;
this.income = income;

public Long getId() {
return id;

public Float getIncome() {
return income;

public String getName() {
return name;

public Integer getYearsExperience() {
return yearsExperience;

@Searchable() annotation, tells to compass that User object to be indexed.
@SearchableId() annotation, to mention unique id to refer the object.
@SearchableProperty() annotation, helps to what are the property to be index

3) indexUser(Compass) method used to index the user object.

public static void index(Compass compass) {

CompassSession session = compass.openSession();

User user1 = new User(2l, "jp" , 100, 140000.0f);

CompassTransaction tx = session.beginTransaction();;


This method cache the user1 object to memory.

4) searchUser(Compass) method to search user1 object.

public static void searchUser(Compass compass) {
CompassSession session = compass.openSession();
CompassTransaction tx = session.beginLocalTransaction();

CompassQueryBuilder cqb = session.queryBuilder();

CompassHits hits = cqb.bool()
.addMust(cqb.term("name", "jp"))

for(CompassHit hit : hits) {
User usr = (User);


we need to create compass session, transaction & query builder. Then get the hits from query builder.
.addMust(cqb.alias("user") line get the user object with help of alias. If we have relational bean this alias help us to search particular object like user, address, customer.

5) Finally main() to index the user object and search the same

public static void main( String[] args ) {
CompassConfiguration cfg = new CompassConfiguration();

Compass compass = cfg.buildCompass();



Output is
hits= 1
Hits is 1, because our criteria matched for only one object.
Here user1 object index to the memory and searched back from the same. As data grows we can't keep it in memory. In that case we can index objects to file system.

Thursday, December 3, 2009

javascript submitting form twice

I have form with hidden fields. When i do change the country select box, taking the value of select box  & updating  the same in hidden field. When i hit the search button to search countries, i am submitting the form using javascript.

My code:

<a href="#" onclick="submitMyForm();">Search</a>

I was wondering this javascript submitted this form twice. First time with the value in the hidden box and second time with out.

We found out the problem with my javascript code. 

Correct code:

<a href="#" onclick="submitMyForm();return false;">Search</a>

So "return false;" did trick for me.

Have fun

Wednesday, July 1, 2009

Password protected application in tomcat server

We can do container level authentication in tomcat server. Tomcat support three types of authentication. DataSourceRealm, JDBCRealm, JNDIRealm, MemoryRealm. For more detail...

we will see implementation of "MemoryRealm". This uses XML file as the source to maintain the username and password.

You can see /conf/tomcat-users.xml file contains the username, password and roles.

Step 1:
You can add new user and roles as follows
<?xml version='1.0' encoding='utf-8'?>
<role rolename="manager"/>
<role rolename="admin"/>
<role rolename="ananymous">
<user username="tomcat" password="tomcat" roles="manager,admin"/>
<user username="newuser" password="password" roles="ananymous"/>

Step 2:
Next thing Enable MemoryRealm in the <tomcat-home>/conf/server.xml file.
By default UserDatabaseRealm is enabled. Comment out this and add the add the MemoryRealm <Realm className="org.apache.catalina.realm.MemoryRealm" />

Step 3:
Have to add the security-constraint in our application's web.xml file. Assume that we have deployed "webapplication1" in tomcat[<tomcat-home>/webapp/webapplication1].
We need to add following security-constraint in <tomcat-home>/webapp/webapplication1/WEB-INF/web.xml.

<web-resource-name>Tomcat User authentication</web-resource-name>
<realm-name>Tomcat User authentication</realm-name>

Role <role-name>anonymous</role-name> applied for all request comes to the webapplication1 for the url-pattern <url-pattern>/*</url-pattern>.

If tomcat container encounter the security-constraint in the web.xml for the given request, it add the authentication header in the response. So broswer popups the window to receive username and password.

IF username and password matches in the tomcat-users.xml, container allow the access the resource.

<auth-method>BASIC</auth-method> defines the authentication method to define the Realm. The possible values are BASIC, DIGEST and FORM.

If our application uses some other security, tomcat MemoryRealm may give issues.

Thursday, June 18, 2009

How to change OS boot priority in Ubuntu

Login as root user.
edit the following file

you could see list of all installed OS here as follows:
Note: I have installed Ubuntu and XP in my machine

Ubuntu 8.10, kernel 2.6.27-7-generic
kernel /boot/vmlinuz-2.6.27-7-generic root=UUID=1d034dd4-58c3-4ae9-abc0-c1b5e4591639 ro quiet splash


Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)

Ubuntu 8.10, memtest86+

Other operating systems:

Microsoft Windows XP Home Edition

The id start from 0.
0 = Ubuntu 8.10, kernel 2.6.27-7-generic
1 = Ubuntu 8.10, kernel 2.6.27-7-generic (recovery mode)
2 = Ubuntu 8.10, memtest86+
3 = Other operating systems:
4 = Microsoft Windows XP Home Edition

The following line is taking care of which OS to boot by default

default 0

this means by default Ubuntu 8.10, kernel 2.6.27-7-generic will be booted

If we want to boot XP as default, change this line to

default 4

save the file. When you boot next time by default XP will be booted.

Tuesday, June 16, 2009

java UnsupportedClassVersionError

While deploy java code into tomcat, it thrown exception as follows

SEVERE: Exception starting filter struts
java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(
at org.apache.catalina.loader.WebappClassLoader.findClass(
at org.apache.catalina.startup.Bootstrap.start(
at org.apache.catalina.startup.Bootstrap.main(
17 Mar, 2009 1:29:25 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext

The problem is version conflict [development machine java version is 1.5 but machine where i deploy has the 1.6 version]

To fix this problem we need to install java-1.6 version in the deployment machine.

Monday, June 15, 2009

JSP form getting submitted twice

When i was working in the struts2,hibernate and spring technology, strangely "null pointer exception" thrown for attribute which used in the form even i give valid input.

I dig this issue and found that, struts action called twice when i request for the URL. Again this also crazy for me. When debug the application, found that browser sending new request if any empty 'src' in the <img> tag present in the code.


<img src="">

In our case browser sent second request with empty form[no data] . so obviously "null pointer exception".

so take out or give the valid image src name and this will fix the problem.

Friday, November 7, 2008

Embed flash in html using javascript

Now a days Web applications embedding flash or video to describe about the stuff. I was came across the scenario where i have to embed flash in my web application.

I found that using javascript is better option.

Find the complete code in the following URL.

This is plain HTML document. One thing you have to take care is source file path. In above URL's document, you could find ####### symbol inside of the body tag.

You have to just replace ####### with your flash file absolute path.
for example...
/home/JP/demo.swf is name of the flash file. ###### should be replace with /home/JP/demo

Have fun.

Thursday, October 9, 2008

mysql replication

While working in application deployment you might have come across the term called "failover database". That means if any hardware problem in the DB server we can't access the database at all. So we have one more DB server to manage the application. When DB1 have some problem we can manage using DB2.

So to achieve this what i thought was have to take mysqldump and import to second server periodically. But there is the better facility in mysql 5.x version called "mysql replication". But mysql 5.1.x is stable for mysql replication. What mysql replication doing is simply coping the mysql-bin log from source DB server to detination DB server. whenever we do any transaction that will be logged in mysql-bin log. So coping mysql-bin log from one machine to another is the soluction for failover database problem.

For mysql replication just we need to change some configuration in my.cnf file.

you can find this file using the following command

find . | grep my.cnf

i) Edit the my.cnf file in server1[uncomment the line server-id = 1 by default commented]
server-id = 1

ii) Edit the my.cnf file in server2 [Uncomment the following entries and give proper values]
server-id = 2

master-host =
master-user = repl
master-password = password
log-bin = mysql-bin


master-host : DB server1 IP address.
master-user : this user should have all privileges. While create this user use the follwoing command to grant permission.
GRANT ALL PRIVILEGES ON *.* TO 'user'@'host'
IDENTIFIED BY 'some_pass';
master-password: password of the master-user

iii) Restart the mysql server using the following command

/etc/init.d/mysql restart

Whenever we do data manipulation both server will have same data and in sync. Now failover database is ready. This is the way to do mysql replication.

Thursday, October 2, 2008

Synchronize directories/files between servers

I came across the scenario where, we have to synchronize files and directories between different servers. For example[Refer image1] my application update images in server1 only. But the same image shoule be synchronized in server2 also.

There is tool 'Rsync' for linux to acheive this scenario.
Install Rsync in two servers. We are going to sync server1 with server2. So here destination server is server2.

In server2 add the following configration files.

i) Create rsync.conf file in /etc/rsync.conf
Add the following code given in between two lines in this file.
motd file = /etc/rsyncd.motd
log file = /var/log/rsyncd.log
pid file = /var/run/
lock file = /var/run/rsync.lock

path = /var/www/html/images
comment = Image Server
uid = apache
gid = apache
read only = no
list = yes

First four lines are log,pid,lock and motd files path

[thumbnails] is the label. This will refered in server1 to send the directories to server2.
path is the place where the directories and files will get stored.

ii) Create rsyncd.motd file in /ect/rsyncd.motd

Add some text. This will shown at the time of sync.
For expample add text like in between two lines.
File transfering.........

iii) By default rsync is disabled. So we have to enable Rsync. You can edit the file /etc/xinetd.d/rsync and chage the line as disable = no [by default disable = yes]

iv) Start the rsync server
/etc/init.d/xinetd start
Server2 [Destination server] configuration over.

In server1, only one line command will sync the file or directories to server2.

rsync -rptgou /absolute path/images

rsync ==> is the command
-rptgou ===> is the options
/absolute path/images ===> images is the directory we are going to transfer to server2 ===> this is the server2 ip and thumbnails is the lable we have added in "rsync.conf" configuration file in server2

We can add the above command in crontab so that two servers in the sync.

Monday, September 29, 2008

MySql ERROR 1054

I was breaking my head when i was doing import data from mysqldump in Linux machine. The problem was "ERROR 1054 (42S22) at line 1564: Unknown column 'cust.CUSTOMER_NAME' in 'field list' ". I surfed the net but i couldn't get any stuff.

Then i put this problem on my guru[Mukund]. He explained the problem.

MySql behave as case-in-sensitive in microsoft environment. So while writing function, procedure and trigger case is no issues in microsoft environment. But in case of Linux, MySql behave as case-sensitive. All the development machines were Microsoft Environment. Production environment is Linux.

To fix this problem [To make Linux case insensitive] add the following line in the file /etc/mysql/my.cnf
lower_case_table_name = 1

This line make MySql case-in-sensitive in linux environment.

Tuesday, September 23, 2008

HTML Redirect to new URL

This is very useful when we want redirect from one page/site to other page/site.
For example the following code written in home.html. Whenever you clicked on this home.html link, browser will take you to

<meta equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta equiv="REFRESH" content="0; URL=">

Here http-equiv="REFRESH" tag reload/redirect the page after the mentioned time in the content tag.
Content=0 means immediately redirect /load the page.

Friday, September 19, 2008

Mysql Error : Mysql has gone away.

I had a problem while import database from my server to local around 117MB size. Suddenly i got in a problem. That was "Mysql has gone away". I surfed the net and got the solution.

When mysql server receives packet more than mentioned in max_allowed_packet in mysql server configuration, mysql server throw out the error "Mysql has gone away".

To fix this problem you can change max_allowed_packet value in my.cnf file in linux machine. This file will be in /etc/mysql/my.cnf

max_allowed_packet = 36M

Restart mysql.

Thursday, September 18, 2008

How to Run Unix shell script in java

I came across the scenario wherein i have to call/ Run the unix shell script. I think this would help you guys.

I have written a script called code:

cp /home/ /home/

In this script just i am copying a file to another.

The java code to call that script.

public class CallScript
public static void main(String s[]) throws Exception{
Runtime rt = Runtime.getRuntime();
try {
String str = "/absolute_path/";
Process child = rt.exec("/bin/bash");
BufferedWriter outCommand = new BufferedWriter(new Output
outCommand.write(str +"\n");

} catch (Exception e) {

Monday, August 25, 2008

Apache load test tool

For web application, to test server load is important one to check the performance.

If you have installed apache in your machine, you could use "ab"[apache benchmarking] command to test the server load.


ab -n 100 -c 100


ab ---> apache command
-n ---> number of requests
-c ---> number of concurrent requests.

for more info

Wednesday, August 20, 2008

How to change default size of terminal [Ubuntu]

You can edit the following file with root access.

The following entry is the one we have to change.

To change the number of columns, change the co# number, in this case 80.
To change the number of rows, change the li# number, in this case 24.
So as an example if you want a terminal window of 80x54:

Now the terminal size would be half of the screen.

Thursday, July 31, 2008

clone hard disk in linux

Install all software for development machine is tedious job. Just think of a team of 5 or above. Linux offer DD command to reduce this job as much as easier.
What we could do with the help of DD command is, just install all the software in one machine and clone that hard disk to other hard disks. Here the constraints is hard disks[source and destination] should be same size.

Step 1:
Install all softwares you want.
Step 2:
Connect the second hard disk to machine where in all software has been installed.
Stop 3:
Mount command list all the media connected in that machine.
Stop 4:
Now you have find out in which hard disk you have already installed all software.
Now two hard disk connected to your machine.
but you can view only one hard disk unless you mount another one. To confirm which media is source and which media is destination, You have to mount.
While run DD command we have to give the name of the media namely sda or sdb etc... So we have to confirm the media name.
To mount
i) Make a directory in /media. For ex /media/hd
ii) run a follwoing command to mount media to a directory.
mount /dev/sda7 /media/hd
/dev directory will contains all media details.
iii) after confirmation of which media is source[for ex sdb] and which media is destination[for ex sda] have to unmount the device using the following command.
umount /media/hd
step 5:
finally you have to run the following command to clone the hard disk from one to another with root user.
dd if=/dev/sdb of=/dev/sda

dd => disk to disk command
if => input file
of => output file

This will take an hour to copy. You could do the same stuff for any number of machines within an hour per machine.
Enjoy maadi.

Tuesday, July 8, 2008

Sort process by memory

The following command help to sort list of process running in linux machine.
ps -eo pmem,pid,args | sort -k 1 -n -r | less

pmem -> list the memory occupied by the process
pid -> process ID
args -> process

Friday, June 20, 2008

database dump for mysql and postgreSQL

User's data is very very important. Obviously most of application stores user data in the database.

Database backup is mandatory those who are use user data in their application.

If something happen to database, using dump we can restore the backup to the database.

MySql database:
To dump/export:
mysqldump --user {username} --password {password} {database} backup.sql

mysqldump is the command to dump/export the database to file.

To undump/import:
mysql --user {username} --password {password} {database}
This will extract backup.sql to the database
PostgreSQL database:

To dump/export:
pg_dump -h {host-name} -U {username} -p {database name} backup.sql

pg_dump is the command to dump the database. The above command dump all data in the database {database} to the backup.sql file.

To undump/import:
psql -h {host-name} -U {username} -p {database name} < backup.sql
Dump/Export postgreSQL database:

Same as mysql this command will import data from backup.sql to the database.

Monday, June 9, 2008

compile lighttpd server from source

To install any server like 'lighttpd' for windows operating system we can download and install using .exe file.
Same way we could do it for other operating system [sun solaris, linux and mac]also. But for some specific distribution there won't be any executable version of software.

In this case, we can compile from source code and install the same.

I explained installation steps in the ubuntu[linux distribution] server.

Login as root.

There is two way to download the source code

1) Using terminal:
Copy the url of the software which we want to install. That might be any kind of compressed format. for ex:[tar.gz,tar.bz2,etc...] and use the following command
wget {URL}
this will downloads source code using terminal.
2) Using GUI
Click on download link and save to local file system.

Steps to compile and install:
i) Uncompress the file which one we downloaded. Using the following command in terminal
if downloaded file is .tar.gz format use tar -xzvf {downloaded file name}
if downloaded file is .tar.bz2 use tar -xjvf {downloaded file name}

ii) Get inside the folder and there is file named "configure" and type the following command
if we want install in any specific directory, mention directory using the following command.
./configure --prefix = {directory}.... [default installation directory is /opt/
The above command will configure the compilation environment.

iii) Type the following to compile
now source code compiled.

iv) To install
make install
Now server is installed and ready for you.