Thursday, August 10, 2006

Ajax Hangs in Safari

At my recent gig, Zingku, I have been doing some heavy duty AJAX. There was one particular bug in Safari that I wanted to share with folks that took a while to figure out.

Our environment uses Tomcat as its servlet engine and only on Safari we would experience these random hangs in some AJAX based requests. These AJAX requests would never leave the browser and were difficult to reproduce. However, they happened often enough to frustrate us. The lack of debugging tools in Safari made things very difficult.

Well, after a weekend of digging into the problem I figured out the magic URL that caused the hangs to occur. Safari would just hang on AJAX URLs that contained the character ";". The reason it was hard to find was that we do not explicitly generate URLs that contain the ";" character. Tomcat does in the form of a ";JSESSIONID=magic_number" token when it thinks the browser does not have the right session cookie. This is what made it feel random.

The solution was to encode the ";" prior to feeding the URL into the XMLHttpRequest.. Here is how you can do it using a quick localized hack:

url = url.replace( ';', '%3B');

I hope Apple will introduce some better debugging tools for Safari in the future.

Run away from EJBs

I came across this article (Java EE Fallacies: EJBs are too complex, POJOs are easier.).

EJB, at least EJB 2.0, was one of the most over engineered and painful frameworks I have ever used. Given how bad the taste EJBs left with me, there is nothing any updates will do to get me to ever use or consider them for anything.

The author talks about non-functionals such as "real time monitoring (JSR-77), threading, proper load balancing etc" are just plain over engineering again. These requirements should not be solved by the mother of all frameworks. My experience suggests that these requirements need to be hand tuned for the app and by the app, not some advanced solves world peace framework.

Given the EJB experience what I suggest to any developer is to evolve from SIMPLE working systems as opposed to starting a project with the goal to solve everything. Grow into your requirements and iterate furiously.

PS. I can see some previous colleagues telling me, "I told you so" when we first starting using EJBs. Right Bob and Brian :)...

Sunday, August 06, 2006

Volunteer work for an eight-billion-dollar corporation

This is an amazing story of the ultimate skunk works project..