My Personal Online Recycle Bin
You may find something useful here...........

Friday, December 30, 2005

Integrate Apache mod jk and struts action (*.do)

This week, I have implemented a new small module (built with struts framework) in the testing server. After implemented the module, I tried to run one round of testing to test the modules. At the beginning, everything was fine until when I click on my module link (http://xxxx/xxxx/xxxx/xxxx.do). I was expecting the modules loaded in a new browser. A new browser did appear but it was a no page found error page. I was stunt because I have no idea why my page didn't showed up. I have already run this modules n times in my local machine. And everything is fine.

Then I start to investigate what is possible problems. May be the jsp is in wrong directory, may be the path in configuration file have typo mistake and etc? But I am sure whatever possible problem in my mind should not be the right because if is those problem, it will showed an error page and not an empty page.

Suddenly I thought of may be the envionment is different. The testing server is running apache for load balancing while my machine is not. I quickly did a search in google for apache configuration (I have never setup a apache server) and find the possible solution.

The solution is as follow:


Under document root add this
JkMount /*.do loadbalancer
JkMount /WEBAPPS/* loadbalancer


The "JkMount /*.do loadbalancer" tell the apache to load balance for all files end with .do. While the "JkMount /WEBAPPS/* loadbalancer" is to load balance all the files under your WEBAPPS path.

If you are interested to know more about configuring apache with tomcat, please read Apache 2.x + Tomcat 4.x + Load Balancing (or Private JVMs). Lastest apache tomcat connector can be download here

Tuesday, December 27, 2005

My doubt on King Kong movie

Last friday night, I watch the King Kong movie with my colleague. The movie was nice, but my mood was totally interrupted when the person that sat behind me open his/her mouth. Because he/she have got bad breath.

After the movie, I still have some doubt in my mind.

1) How the King Kong get transfer to US after they have captured it?
2) Why the "wild man" only attack them once since they have been on the island for some times.
3) Did the girl(so called beauty) really love the king kong?

And one of my colleague ask 2 very funny question that I don't know how to answer.

1) How long to take for the king kong to grow in such a big size?
2) The turtle longer life or the king kong?

Wednesday, December 21, 2005

NoClassDefFoundError.........

Today, I got a NoClassDefFoundError error message when I tried to execute a java program from command line with "java classname" in a linux environment.

I was so suprised because the class should be working perfectly fine. This is because this is a utility class that is used in a web application which is executed everyday. All the required class must be there. Else program should not run and the user should have complaint already.

I wonder may be I am in wrong working path. So I print the working directory and list the files under the path. Everything was fine. The path is correct and the class file is there. Then I triead again with "java classname". Miracle didn't happen, I get the same message.

After a few different fail attempt, I finally succesfully call the program with "java com.xxx.xxx.xxx.classname". Yes......I successfully call the program with a fully qualified class name. But I don't understand why do I need a fully qualified name to call the program since i am already in the same directory with the class????

After a serch on google, I found the following that give me some info on the error message.
There are two major types of class path problems. The first occurs when a Java class you are trying to use is not found in the class path, so it throws a java.lang.ClassNotFoundException exception. The second problem occurs when the class you are trying to use is found, but one of the classes it imports is not found. In this case, at compile time the imported classes were present, but at run time the imported class was not part of the class path. This will throw a java.lang.NoClassDefFoundError exception. Another way to think of the NoClassDefFoundError is to say that the searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found at runtime. Full article can be found here


Anyway, I still don't understand why I need to used a fully qualified name to call the class. May be some one can clarify my doubt.

Monday, December 19, 2005

Grep java process running in linux environment

Last week, my colleague ask for my assistance to found out is a java process still running in a linux machine.

Firstly, I used the ps -ef command to list all active process. But there is too many process running. Thus I narrow down my search by specifying ps -ef |grep -i java. But, still there is multiple process found.

I can't be sure that is the specific java process is still alive or end becasue the ps command don't give enough info which java process is running. So I can only tell my colleague that few java process is running but I am not sure is the specific java process still running.

After that incident, I have tried to search in google and some other site. But also didn't found any solution/way to find out whether a specific java process is running. So I decide to post this question/problem here. Hopefully, may be you can provide a solution to me. Or may be later, I will found a solution later. And share it with you.

Thursday, December 15, 2005

Hibernate 3.1......Running First Sample Application

Today, I have just downloaded the hibernate 3.1. Right after the download completed, I tried to run the sample program according to the step in "Getting Started" page. After I setup everything accordingly, I execute the program and expect everything run smoothly.

But I am so disappointed because it give error that the source files cannot be compiled. After spending some times, I managed to figure out that hibernate 3.1 need Java 5 tiger to compile the source file.

After setup the Java 5 jdk in my environment, I successfully run my first hibernate sample application. YAHOOOOOOO..........

Anyway, I am still not clear on the flow and architecture of hibernate. Hopefully I can learn it fast.

Wednesday, December 14, 2005

Traversing XML DOM Document - IE and Netscape Problem.

Yesterday, i was facing a problem to traverse a xml DOM document.

The problem was the java script code work differently in IE and netscape 6/Mozilla. The Code is as follow:

nodeBody[0].childNodes[j-1].firstChild.nodeValue;

The code work fine in IE but not in netscape 6 / mozilla. But if the code is change to

nodeBody[0].childNodes[j-2].firstChild.nodeValue;

Then it work in netscape but not IE. So I feel very odd. And wanna to find out why so.

After a quick search on google, i found the answer to my question and solution to the above problem.

Why same code behave differently in IE and netscape?


This is because in NS6 (and Mozilla), white spaces are considered elements as well (TEXT), while in IE, they are not.


Solution to this problem is as follow

//Regular expression used to match any non-whitespace character
var notWhitespace = /\S/

function removeWhiteSpace(){
//Cache "messages" element of xml file
var msgobj=xmlDoc.getElementsByTagName("messages")[0]

//REMOVE white spaces in XML file. Intended mainly for NS6/Mozilla
for (i=0;i<msgobj.childNodes.length;i++){
if ((msgobj.childNodes[i].nodeType == 3)& &
(!notWhitespace.test(msgobj.childNodes[i].nodeValue))) {
// that is, if it's a whitespace text node
msgobj.removeChild(msgobj.childNodes[i])
i--
}
}
}


For the full article on this issue, you can refer here.

Tuesday, December 13, 2005

由頭到尾得一個人

I read the following post in a forum and found it quite special. So I would like to share it with you. Anyway, it is in chinese and i don't plan to translate it. So now you know the impotance of chinese!!!!!!! hahaha.........
由頭到尾得一個人

一九四五年的一天,克力富蘭的孤兒院裡出現了一個神秘的女嬰,沒有人知道她的父母是誰。她孤獨地長大,沒有任何人與她來往。

直 到一九六三年的一天,她莫名其妙地愛上了一個流浪漢,情況才變得好起來。可是好景不長,不幸事件一個接一個的發生。首先,當她發現自己懷上了流浪漢的 小孩時,流浪漢卻突然失蹤了。其次,她在醫院生小孩時,醫生發現她是雙性人,也就是說她同時具有男女性器官。為了挽救她的生命,醫院給她做了變性手術,她 變成了他。最不幸的是,她剛剛生下的小女孩又被一個神秘的人給綁走了。這一連串的打擊使他從此一蹶不振,最後流落到街頭變成了一個無家可歸的流浪漢。

直到一九七八年的一天,他醉熏熏地走進了一個小酒吧,把他一身不幸的遭遇告訴了一個比他年長的酒吧夥計。酒吧夥計很同情他,主動提出幫他找到那個使『他』懷孕而又失蹤的流浪漢。唯一的條件是他必須參加夥計他們的『時間旅行特種部隊』。

他 們一起進了『時間飛車』。飛車回到六三年時,夥計把流浪漢放了出去。流浪漢莫名其妙地愛上了一個孤兒院長大的姑娘,並使她懷了孕。夥計又乘『時間飛車』 前行九個多月,到醫院搶走了剛剛出生的小女嬰,並用『時間飛車』把女嬰帶回到一九四五年,悄悄地把她放在克力富蘭的一個孤兒院裡。然後再把稀裡糊塗的流浪 漢向前帶到了一九八五年,並且讓他加入了他們的『時間旅行特種部隊』。

流浪漢有了正式工作以後,生活走上了正軌。並逐漸地在特種部隊裡混到了相當不錯的地位。有一次,為了完成一個特殊任務,上級派他飛回一九七零年,化裝成酒吧夥計去拉一個流浪漢加入他們的特種部

First Blog in my Life............

Hehehe.......................

Hi to all,

This is my first ever blog in my life!!!!!!!!!!!!!!!

And this also is my first ever diary that I have wrote not for home work.............

Hahaha............

I would like to keep my first post............short and sweet!!!!!!!!!!!

So I will stop here.....

Hope you will enjoy your visit......

Bye.....