Eclipse loading problem : XPCOM error

November 3, 2008 by samindaw

If you are an eclipse user you may have come across this error atleast once in you lifetime. Sometimes this error shown as a message “Widget disposed too early” or something like that. To be more precise when starting eclipse it just hands on a small blank dialog kind of form after specifying the workspace. You cannot close or exit from this form. It just hangs.

This happens mostly in linux. I experienced this in ubuntu hardy with Ganymede mostly. If this happenes first thing you should do it to verify the problem. Just check the log for the workspace to see what the exception thrown before eclipse hanged. For example in our case it will be something like this.

Exception in thread “Thread-1″ org.eclipse.

swt.SWTError: XPCOM error -2147467262
at org.eclipse.swt.browser.Mozilla.error(Mozilla.java:1360)
at org.eclipse.swt.browser.Mozilla.setText(Mozilla.java:1564)
at org.eclipse.swt.browser.Browser.setText(Browser.java:716)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.setInput(JavadocView.java:531)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.refresh(JavadocView.java:452)
at org.eclipse.jdt.internal.ui.infoviews.JavadocView.setBackground(JavadocView.java:439)
at org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.inititalizeColors(AbstractInfoView.java:327)
at org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView.createPartControl(AbstractInfoView.java:191)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:372)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.j……

…..

Now for the solution.

Well the solution is a bit murkey. I came across the worst path of solving the problem with the only solution available. Eclipse uses XUL (spelled “zool”) for its GUI rendering when in linux. This is kind of weird because the actually reason i figured out is that it uses the platform current browser to do that for him. This in the case of linux where the default browser is most of the time is Mozilla Firefox, eclipse uses the functionalities of firefox to render its GUI. If in the case of windows it uses IE as I can remember. This is why the above exception contains the words like “browser” “mozilla” etc.

Anyway the problem occures due to a simple reason, the firefox browser does the rendering using the xulrunner. There is a default xulrunner when firefox is installed and this version is not updated enough for eclipse. Thus it cannot render the UI parts and the UI widgets are disposed not being able to be created correctly. So the easy solution is to update the xulrunner.

You can do a simple

$apt-get update xulrunner or $apt-get install xulrunner

Works most of the time. But sometimes its best to do a system wide upgrade using

$apt-get upgrade

because there is a version firefox which xulrunner also supports, and if the firefox is old (or in 3.0beta for eaxmple), the xulrunner will not get updated properly.

So after that the eclipse should work fine. But mind you, you might want to start on a fresh workspace anyway.

But i have seem in some instances where eclipse can start on a already created (and previously worked) workspaces. Yeah i know, WIERD!!!

Well In my case this worked great on eclipse, but with a hitch. The firefox was giving trouble now. The address bar not working properly, icons in the title bar disabled, No history or bookmarks shown etc. It looked like the upgrade messed up the firefox.

With a little bit of searching I found that this can happen if the firefox profile gets corrupted. For those of you who does not know what a firefox profile is, its just a simple profiles created by the firefox to keep track of each and every uses preferences/history/bookmarks/etc etc.

So all you have to do is to create a new firefox profile abadoning the one you already have. Google for how to create a new profile. For those of who wants to keep the old one all they have to do is to go and rename the “localstore.rdf” file to say “localstore.rdf.tmp” and restart the browser. (This file is normally located in “~/.mozilla/firefox/<somefolder_for_the_profile>/localstore.rdf”).

localstore.rdf is the file where most of the settings of the profile are declared. When this file is missing the browser automatically resets the settings for the browser. And you will see that the buttons and icons etc will start working normally again :)

but make sure u rename the “localstore.rdf.tmp” back to “localstore.rdf” after the browser resets the settings. Because if not eclipse again will start giving problems and this time it will not be specific on what the problem is. It will not even mention that the problem is with the profile of the browser. It will just not behavie as you expect and make you think there is something wrong in you code (because most of the time it doesn’t throw an exception also). In my case this happened to me. Where i was not able to add a dynamic project to the tomcat server as the runtime environment. We can add the dynamic projects to run with the tomcat server from the left list box to right list box (if u can remember). Both the list boxes will just remain empty. And there will be no hint on whats exactly wrong. So i restored the localstore.rdf file and it started working again.

Hope this helped anyone. Dont want someone else to waste a day to solve this problem.

Live Editing a Web Service or Making use of Axis2 Hotupdate feature in a cool way.

October 17, 2009 by samindaw

This is to inform that we now support the feature of making use of the hotupdate feature in axis2 web service feature.  Try this tutorial http://wso2.org/library/tutorials/live-edit-your-axis2-web-service-using-eclipse for more details. Basically it allows you to test your web service while you edit it. Really cool.

How to write a axis2 web service within seconds

October 9, 2009 by samindaw

It is literally within seconds, given that you already have the java class which you intend to make it a web service.  Here’s the link http://wso2.org/library/tutorials/create-axis2-web-service-3-steps-using-eclipse. Will write a web service  which would be more close to a real world scenario next time. Any thoughts of improvement is welcome.

How to write a web service client with just 3 steps

October 9, 2009 by samindaw

I recently wrote an I article to WSO2 OT regarding creating a client to consume or should I say access a web service. Didn’t explain a complex scenario though. Only showed the simple case of accessing a Web Service. This is the link to access the tutorial http://wso2.org/library/tutorials/creating-web-service-client-3-steps-using-eclipse. Thinking of writing a tutorial with a more complex scenario of handling security or binary uploads/downloads.

තල මල පිපිලා – Thala Mala Pipila

September 15, 2009 by samindaw

I think it was about more than 10 years ago when I last watched a stage drama. And that was මනමේ (maname), back when I was in school. Before that it was a stage drama called කැඩපත (kadapatha) – I barely remember that one. Even though I wasn’t dyeing to see another one, I always wanted to go watch a stage drama just for a change to all the big screen (wide-screen, lcd screen, television screen) movies. After missing several opportunity I finally got a chance to watch the famous stage artist Jayalath Manoratnes (ජයලත් මනෝරත්නයන්) thala mala pipila (තල මල පිපිලා) stage drama today.

When the drama started I was captured by the strange lighting that was made in the stage focussing the attention on a person wearing on a robot costume. Eventhough the constume wasn’t good enough to pass for a real robot, it made me feel that we are about to enter to a strange world. I sat up straighter on my chair. The year it said was 4000 AD. It explains that they no longer pocess anything called tradition (සම්ප්‍රදාය) or emotions (හැඟීම්) but there were a species called humans millenniums ago who did have it. The robot wanted to share one such historical scene with us. It was one of the wierdest way of stepping in to a story, but nonetheless the surrounding the lighting and the synthesized voice made it very interesting.

The story starts up from that point onwards, and I wont explain what the story is, because I would probably ruine the greateness of such an artistic creation just by trying to make you imagine what it was like. But I must say the attention to the details, the lighting, the music, the hilarity and the magnificent performance of the stage actors did not stir me even anything close to bordem. It kept us interested right until to the end.

Now I’m officially a sri lankan stage drama fan :)

Why did the war in SL went on for more than 20 years?

September 15, 2009 by samindaw

This is not entirely accurate, but close enough analogue. Found on the internet.

The 8 Monkeys

(This is reportedly based on an actual experiment conducted in the U.K.)

Put eight monkeys in a room. In the middle of the room is a ladder, leading to a bunch of bananas hanging from a hook on the ceiling.
Each time a monkey tries to climb the ladder, all the monkeys are sprayed with ice water, which makes them miserable. Soon enough, whenever a monkey attempts to climb the ladder, all of the other monkeys, not wanting to be sprayed, set upon him and beat him up. Soon, none of the eight monkeys ever attempts to climb the ladder.
One of the original monkeys is then removed, and a new monkey is put in the room. Seeing the bananas and the ladder, he wonders why none of the other monkeys are doing the obvious.  But undaunted, he immediately begins to climb the ladder.
All the other monkeys fall upon him and beat him silly. He has no idea why.

However, he no longer attempts to climb the ladder.
A second original monkey is removed and replaced. The newcomer again attempts to climb the ladder, but all the other monkeys hammer the crap out of him.

This includes the previous new monkey, who, grateful that he’s not on the receiving end this time, participates in the beating because all the other monkeys are doing it.  However, he has no idea why he’s attacking the new monkey.
One by one, all the original monkeys are replaced. Eight new monkeys are now in the room. None of them have ever been sprayed by ice water. None of them attempt to climb the ladder. All of them will enthusiastically beat up any new monkey who tries, without having any idea why.

Search & Replace Strings Considering the whole file (non line-based) using ’sed’ command

August 15, 2009 by samindaw

This was really stupid of ’sed’ command. I had a file which had 2 occurances of the same string in 2 different lines and i wanted only the first to be replace by some other string. Took me a while to figure out why the conventional sed command doesnt work. (Incase you are wondering its because sed is a line-based command. i.e. reads a line from input, apply the whole sed logic and the mentioned operations in it, print the output and repeat the whole process for the rest of the input lines).

so anyway what you have to do is pretty simple. either you have to format your input to remove the new line characters and feed that as the input and somehow reintroduce the newline character after sed was applied, or feed the whole input to sed in a non-line-based form. Anyway found this on the net. http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/.

So coming back to what I wanted to do,

$ cat myfile | sed ‘:a;N;$!ba;s/originalstring/replacestring/’

notice the bolded characters added in the sed command. They are the extra addition to the conventional sed command we use for seach and replace strings.

අතීතය සිහිනයක් පමණයි…..

July 8, 2009 by samindaw

This is a song which I’ve heard so often, but never appreciated its meaning before now. It is all about letting go of the past. Being humans we always tend to live in the past. Some of us more than others.

Here’s the lyrics

අතීතය සිහිනයක් පමණයි
සැබෑ සුවඳක් නෑ.......
එදා සෙනෙහෙන් නොබැඳුනානම්
මෙදා වියෝවක් නෑ.....

තැනූ මන්දිර බිඳී වැටුනත්
නෙතේ කඳුලක් නෑ....
සිනහ වෙන්නට වරම් නොලදත්
සිතේ කිලුටක් නෑ.....

අතීතය සිහිනයක්........

සොබා දහමට නොවන අවනත
ලොවේ කිසිවක් නෑ.....
ලොවේ පැරදුම මිසක කිසිදා
ලැබූ දිනුමක් නෑ....

අතීතය සිහිනයක්........

Listen to the song අතීතය සිහිනයක් පමණයි – කරුණාරත්න දිවුල්ගනේ

How to trim a string using linux bash script

July 3, 2009 by samindaw

This is pretty simply done using the sed command. All you have to know is regular expressions.

To remove leading white spaces

sed 's/^ *//g'

To remove trailing white spaces

sed 's/ *$//g'

So as an example,

$ echo "  aaaa   bbbb      " | sed 's/^ *//g' | sed 's/ *$//g'
aaaa   bbbb

Thats it.

How (NOT) to Make Decisions

June 17, 2009 by samindaw

3 golden rules. Never ever ever ever make decisions when,

  • you are extremely sad (Because you wont see what you haven’t lost)
  • you are extremely happy (Because you wont see what you have lost)
  • you are extremely angry (Because you wont see what you may loose)

patch command in linux to apply a svn patch

June 3, 2009 by samindaw

First of all how to create a patch if you dont know…
$ svn diff mychangedfile1 dir1/dir2/mychangeresource2 > mypatch.txt

To apply this patch it needs to be in the same svn location as the patch was taken. Then using the patch command u apply the patch
$ patch -p0 < patch.txt