Thursday, May 29, 2008

Funny Unix Symbolic Link to Windows Server issue

I faced this while doing deployment of one system to a unix server.

There is a folder/directory which is the symbolic link to a folder hosts at a windows NT server.

It is meant for clustering. The idea is 2 servers put the files/documents at the same folder at one location.

So, everytime i build my source code and deploy the war file at the unix server, i will run a program which runs the data migration. During the process the program will make use of the "open office service" that resides behind the operating system to create document such as Word and put at that particular folder as mentioned above.

Nightmare came. System kept throwing errors. The error message said it has something to do with "wrong code blar..".

I thought it was due to my code. Then I spent days to investigate the problem and to examine my code. It was a wrong move, a waste of time because in the end i found out that it is actually the program failed to create new directory! Ok reason found. The funny thing is, i tried to create the directory using unix shell command manually but failed! I did a list files command and found out that there is no such folder! But why did Unix say the folder is there? Ain't it funny!

Later i discovered that the folder is actually hidden. However i still did not manage to remove the folder by using the "rm -f ." command. From the net i know that this command works all the time to remove hidden directory. Clearly it did not work out in my case. So how now?

Finally i recreated the directory that the Unix claimed exist at the Windows Server, which is the "parent" cluster machine that holds the folder. After that i removed the folder again from the Shell at the Unix server. Yahoo! This time everything is back to normal! My program ran successfully!

What a waste of time. Was in the wrong direction. The Open Office Service should throw a more "exact" or "meaningul" message.

Nevertheless, I still do not know WHY and HOW did this problem happen! I only know the solution so far!

Somthing about Set in Java

Well, if you read about the Java API, you will know that Set will only add object that does not exist in the Set itself. You must be aware of this especially when working with Hibernate! Here's my experience:

I was trying to add a few objects in a Set and set this Set. Then I found out from the database that there is always only ONE object added. I did a debug and found the size of the Set is always > 1 !!!

What happened? Here is my answer from torough checking:

Only the 1st object had been added to the Set. It is because the rest are actually "equal" to the first object so Set does not take them anymore! Bear in mind that each object differs from each other using their ID field. They do have their own ID yet when they are being added into the Set so they are rejected by the Set!

Thus, i have to save each object first before adding them into the Set. The reason is the ID will be generated by Hibernate for each object. The Set knows that they are NOT EQUAL right now then they will be added.

Busy and depressing week!

Since last week i have been working on a data migration project. I am supposed to get it done before the system went live last Friday. However due to the totally different table structure of the old database, the data migration unfortunately did not go smooth. Since then i have been working like hell to get the data correct till now.

What makes me most frustrated is i always need to take some moments to perform a few steps to test my correction! I have already done my best to simplify the steps!

This process has resulted me to only have a very little hours of sleeping time for a few days continuously!

I hope it can quickly goes live asap!

So now, back to Work!!! back to Work!!!!

Friday, May 16, 2008

Finally stock market crossed 1300 points!

After having fluctuated for several weeks, finally KLSE(Malaysia Stock Exchange Market) soared to over 1,300 !!! It is the highest record since the tragedy on 10th March 2008!

Despite the good news of KLSE, over the 4 counters i am holding, 3 of them actually dropped today including the prominent Public Bank! Well, the decline does not really matter to me because overall my portfolio still generates a book yield. I would like to express my gratitude to the Public Bank! It has been performing very very well since the day i bought its shares.

I think my mutual funds' price will rise further following by today's good performance of KLSE. Looks like i am going to do another time of switching in a few weeks time.

Good day!

Wednesday, May 14, 2008

Switched mutual fund to protect my profit!

After 22 months(almost 2 years) of buying Public Ittikal Fund, finally today i decided to switch to another fund to protect my profit.

The return rate of the fund is very impressive. It achieved a total return rate of around 39% which also means around 20% per year on average. Since the day i bought this fund i have been very confident of it as it has a handsome history. The statistics told me this fund is really worth to buy! Back then i really took a lot of time to actually study each funds and also compare each of them before i made my move.

Too bad i missed the golden moment last year. The fund raised so remarkably. At one time it even achieved an overall return rate of more than 40%! I damn regret now! I should have sold it off during that time! Well, one of my customer chose to sell his fund off last year. It so happened that he needed money during that time. Thus he managed to enjoy the 40%++ of return rate! Oh yes, he bought Public Ittikal too because i am the one who recommended this fund to him!

Luckily after the huge decline of the KLSE stock market due to the 'Political Tsunami' which took place on 8th of March 2008, Public Ittikal's price has been gradually restoring to the level which reflects its actual value.

The big drop of March really taught me a lesson. I decided not to be so greedy anymore. To me, 20% of return rate per year is considered a great achievement already. That's the standard practiced by Warren Buffet all this while!

After several days of serious thought, this noon i went to the nearest Public Mutual branch and did the switching. Anyway that was my first ever fund switching.

I switched the fund units to 2 different conservative profile funds.

Tuesday, May 13, 2008

Ali rustam had supper at Subaidah Cafe

Just now, I had my supper with my friend at one cafe called Subaidah. We spent there for around 2 hours more. When we were about to leave, we saw chief minister of the Melaka state, Ali Rustam came together with one of his friend. I think he just finished OT? Haha.

Anyway, as he showed up, a group of customers from the table next to us quickly dashed forward to shake hand with him. Wow! Do they really need to do that?

Monday, May 12, 2008

Apache POI

I have one web application, everytime i deploy i will need to load initial reference data again and again.

The amount of these data is huge!

I used to hardcode all these data in my Java file. I organised them properly using data structure such as String array and so on. In my Java file i have a few functions that actually perform the data loading job.

The problem is, It's time consuming and error prone to hardcode each and every data in the Java file.

Therefore, today i decided to put all the data in Spreadsheet program. It is easier to maintain data at Spreadsheet rather than in the Java file itself.

Then i used Apache POI library to read me those data from the Spreadsheet (Microsoft Excel).

Just one time try and it worked fine!

So simple! I was really delighted!

Wednesday, May 7, 2008

One day effort for unknown vm crach of Eclipse during Subclipse installation

WTF,

It took me one day to get the problem fixed. The solution is so simple!

I setup Eclipse at my new laptop. As usual, i also installed the Subclipse plugin. By right it should work properly. Well, when i tried to create a new remote source repository using Subclipse Perspective in Eclipse, Eclipse just quitted suddenly followed by a prompt saying that it is some kind of memory crash.

Also, there is an error log file generated each time Eclipse exited. However the message is so so not comprehensive.

Here's the message:


## An unexpected error has been detected by Java Runtime Environment:
## EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x3b397bfc,
pid=3824, id=5160
## Java VM: Java HotSpot(TM) Client VM (10.0-b22 mixed mode
windows-x86)
# Problematic frame:# C [libapr-1.dll+0x7bfc]
## If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.


With this only clue, i kept Googling for the whole day and still did not get the problem fixed! How frustated was i!

Besides trying out the solutions found online, I also tried to tackle the problem by doing a few times of trial and error, which is actually install-uninstall this kind of stuff.

We really got to be patient enough when dealing with this kind of problem.

Yet, the problems stayed. All the tries did not bring positive outcome.

Office hour ended. Today i did nothing but just configuring stupid Subversion on Eclipse. Boss, please don't get mad.

I started over the puzzle solving game again at home after coming back from dinner.

With calm mind, and of course enough of rest, i found the answer within an hour!

I came across this article online:

http://subclipse.tigris.org/faq.html#win32-crash

Here's the excerpt:


As soon as I do something with Subclipse on Windows, Eclipse just
crashes. Why does this happen?


This is a fairly recent problem that is caused by a DLL incompatibility. Subversion uses a library called APR or the Apache Portable Runtime. This library has a component called APR-ICONV which is used for translating characters in path and file names to/from UTF8 and the local character set. The release of Apache 2.2 brought with it new releases of APR and APR-ICONV and these are not binary compatible with previous releases.


Subclipse ships with the Apache 2.0 version of these libraries. This crash
occurs if you install an application that installs the Apache 2.2 version of
these libraries AND ALSO sets the APR_ICONV_PATH environment variable to a path that contains the Apache 2.2 version of the APR-ICONV .so objects.


The fix is actually simple. Change the name of the environment variable to APR_ICONV1_PATH. The Apache 2.2 library will look for this environment variable name first, and only fallback to the older name if it is not found. You can safely have an APR_ICONV_PATH environment variable pointing to the Apache 2.0 version of these libraries and the APR_ICONV1_PATH environment variable pointing to the Apache 2.2 version. Subversion 1.5 has resolved this problem by discontinuing the use of APR-ICONV. Instead, Subversion will use translation routines that are provided by the Windows operating system.


So, i uninstalled the Subversion Server built against Apache 2.2 and replaced it with the one built against Apache 2.0.

Eclipse looks fine now.

Finally!