Wednesday, March 31, 2010

Junk Characters while reading Excel using Jxl API

In my project, i have to read some data from an Excel file to use that for showing some data on JSP. Its a multilingual application so data has words in various european langauges. I have used Jxl api to read data from excel file. We have an ant task in our build file which runs at build time and read excel file to make a java file which is further used by JSP to show the data. This build when we run on windows every data in excel file comes correctly in java file but when we run the same build file on unix few of the records come with junk characters.

I investigated this issue and found that Solaris OS locale was default "en " which does not support all european characters. So first i changed that locale to en_US.UTF-8 which supports all European languages.( we have to install separate package to get en_US.UTF-8 locale )

After this change also junk character issue remains the same. Then i checked for the encoding option in the WorkbookSetting() class of Jxl. If we do not specify any encoding for workbook then it takes default encoding for that OS. I tried specifying UTF-8 as encoding for workbook explicitly but it did not work even on windows. Then i tried to get the encoding used by the window by using WorkbookSetting().getEncoding(). Then i come to know that window uses Cp1252 encoding. I then specified this encoding in work book setting using WorkbookSetting.setEncoding("Cp1252"). This solved issue of junk characters for me.

Tuesday, March 30, 2010

Using Eclipse TPTP Tool for Application profiling

One of my web based application has some issues related to performance . So I thought of profiling my application.I searched for the tools available for this and found a lot of tools. After analysis i found that TPTP tools from eclipse is suitable for my use. I installed latest release of eclipse ie. Galelio and futher installed "Test & Performance" tools using "Install New Software " option of eclipse work bench.
After installation i followed the "Tutorials" for using TPTP which was simple. But i could not get the list of collector options in the profile window as mentioned in tutorial. Work Bench keep me showing message "Fetching children of...ector (33%)" and i could not get any collector option in my profile window for long time.

I searched a lot but could not find any solution which worked for me.Then i investigated further and came to know that there is a local agent with the name (ARCServer) which is responsible for showing this collector. I searched in the task manager but could not found any such task. Then i got suspicious that it may happen that it is getting blocked by my local firewall. I turned off the firewall and to my surprise profile window started showing collector option.

It worked one day but next day i again faced the same issue despite of turning firewall off, i could not see collector options. Then i again checked ARCServer process it was not running. Then i thought of checking used ports as i saw in the agent configuration that it runs on port 10002. (You can check it by going to window->preferences->Agent Controller->Hosts). I used netstat -anb command to check that. I found that on 10002 port some other service was running. Then i killed that process and started again profiling. This time it showed me the option and i could profile my application. I thought of sharing it to help people who are facing same issue.