Tuesday, May 18, 2010

Kubuntu 10.04, the aftermath (2)

Now that I had my system up and running, it was time to add some of the applications I love to use. The previous LTS version shipped with Thunderbird 2, whereas the current LTS comes with Thunderbird 3. The new version recognized my existing profile (underneath HOME/.thunderbird, which is where all accounts are kept) without any problems. No mails got lost in the transition. The new version comes with smart folders, which gives an aggregated view on all folders when using different accounts (e.g. webmail, gmail, your ISP's pop mail, ...). My favorite photo management software, f-spot, is also updated and I was very pleased to see it converted my database from the older version without any issues.
In short, all software I used on 8.04 managed to convert my personal settings and data without any problems, which was a relief.

For the rare occasions I still need Windows (only to sync my GPS software with my old PDA, actually), I've set up a virtual machine inside vmware server. Unlike vmware's workstation and fusion, vmware server is a free product. You don't get any fancy stuff with it, like hardware acceleration, but I don't really need this. I also prefer vmware in favor of other virtualization products, like virtualbox, because I'm used to it and it allows me to run virtual machines from work without any modifications. Installing vmware server on a Linux OS with a fairly recent kernel has always been a nightmare. I had a lot of issues installing it on 8.04 and was facing the same issues installing it on 10.04. Thankfully Google was my friend a I came across this thread, explaining in detail how to install vmware on a modern Linux. All you need to do is follow these steps inside a terminal:
cd /usr/local/src
wget http://codebin.cotescu.com/vmware/vmware-server-2.0.x-kernel-2.6.3x-install.sh
tar xvzf raducotescu-vmware-server-linux-2.6.3x-kernel-592e882.tar.gz
cd raducotescu-vmware-server-linux-2.6.3x-kernel-592e882/
tar xvzf VMware-server-2.0.2-203138.x86_64.tar.gz #OF COURSE you have to copy the tar.gz to this dir first..
chmod +x vmware-server-2.0.x-kernel-2.6.3x-install.sh
./vmware-server-2.0.x-kernel-2.6.3x-install.sh

After following these steps, you should have vmware server up and running. Unfortunately you're not out of the bush yet. The console, which is launched from within firefox and connects to the virtual machine's console, is incompatible with firefox 3.6. Luckily, there's a workaround for this. You need to unzip (yes, using the unzip command) /usr/lib/vmware/webAccess/tomcat/apache-tomcat-6.0.16/webapps/ui/plugin/vmware-vmrc-linux-x86.xpi (or vmware-vmrc-linux-x64.xpi when you're running a 64bit Linux) to a temporary folder. When extracted, locate the plugins folder. Inside it, you should find an executable called vmware-vmrc. You should be able to launch it (only from within the folder) and connect to your freshly installed vmware server.



Next, you can select a virtual machine you just started ...



... and your done.



Don't use ctrl-alt-del, use ctrl-alt-print screen instead :)

Hopefully, the people from vmware will release a new version of their server product soon and make sure it's compatible with a more recent kernel and browser.

Wednesday, May 12, 2010

Kubuntu 10.04, the aftermath (1)

I've been using Ubuntu since Hoary, which was released 5 years ago. It has always been, and still is, my preferred OS for desktop computing. April 29th the latest LTS version, 10.04, was released. This week, I decided to take it for a spin.
Being able to upgrade / dist-upgrade on a Debian based Linux system, has always been one of the main reasons why I like Ubuntu so much. In Ubuntu's early days, however, breakage was very likely after dist-upgrading your system. dist-upgrading from Hoary (5.04) towards Dapper (6.06) every six months has been a true nightmare. After that experience, I decided to stick with every LTS version (i.e., 6.06, 8.04, 10.04, ...) and reinstall from scratch. Having my home directory on a separate partition, eases this process a lot. Just reinstall Ubuntu (after backing everything up of course), mount the home partition and your done.
Since I became a big fan of KDE, over the years I've been using Linux, I decided to replace my Kubuntu 8.04 (which was, let's face it, crap) with Kubuntu 10.04. The installation went smoothly and in a matter of minutes I had my new, shiny desktop.
My PC is equipped with an ancient NVidia graphics adapter (GeForce 6 series). Kubuntu 10.04 comes with the nouveau graphics driver, which is an open source effort to eliminate the need for NVidia's binary driver which is, of course, closed source. I am a big fan of open source projects and the community surrounding it, but the nouveau driver is nothing compared to NVidia's binary version.
Since the nouveau driver comes preloaded, I had a hard time installing NVidia's binary driver. First, you have to "apt-get remove" all packages named "something-nvidia-something".
dpkg -l | grep nvidia
shows a list of packages that are pre-installed.
Next, you need to blacklist the nouveau driver, so the kernel doesn't load it while booting. To do this, open /etc/module.d/blacklist.conf and append blacklist=nouveau.
After rebooting, in single user mode, you'll see that nouveau isn't loaded and you can safely execute the NVidia installer script.
Once installed, another problem arises. There is currently a bug which makes the splash screen (i.e. the logo and stuff that appear while booting) looks very ugly after installing NVidia's (or ATI's) binary driver. The people from Ubuntu have provided a temporary fix, enabling a splash screen in 16 color mode. IMHO this still looks like crap, so I disabled the splash screen altogether.
Having to blacklist modules to be able to install NVidia's driver and the crappy plymouth screen is, IMHO, unacceptable. Ubuntu supposed to be a user friendly system. Forcing people to use the nouveau driver is unacceptable as well. I am free to choose whatever driver I want for me graphics card, albeit a closed source driver. Using the closed driver increases graphical performance a lot and the desktop and text look much "sharper". Not so much with the open source driver.
The crappy plymouth screen proves, again, that the people from Ubuntu didn't do their homework and forgot there are a lot of users out there using closed source drivers for their graphics card.
All in all, I am still pleased with my 10.04 install. It looks nice and boots very fast on my 5 year old PC. But somehow, I feel like they failed again to release a Linux distribution, ready for the desktop and ready to replace Windows on the desktop. Maybe we'll have to wait for 12.04 :)

Tuesday, May 04, 2010

When June 1 1900 is not June 1 1900

We're developing a fairly large application in Java. There are 2 front end applications, one written in Flex, the other in plain Spring-MVC and Spring-WebFlow. Both of them are using 3 main applications deployed as 3 different wars on the same application server. The front end applications talk with the back end applications using RMI exposed as HTTP. The back end applications also talk to each other using the same protocol.

One of the applications deployed in the back end is responsible for validating data entered in the front end applications. One of the rules in the, so called ValidationService, checks if the SSIN of a person is valid.
In Belgium, all people have a unique SSIN (Social Security Identification Number), comprised of 11 digits. The first 6 digits are based on the person's birth date. So if this person was born on April 21, 1978, the SSIN starts with 780421xxxyy. To check if an SSIN is valid, you need to check the person's birth date against these first 6 digits. In fact, you need to do a lot more to check if the SSIN is valid, but the issue I was having was related to the person's birth date.

For test purposes, one of the front end applications was running on a Windows machine, while the back end applications where running on a Linux machine (some version of Ubuntu). When entering 06/01/1900 and an SSIN starting with 000106, the ValidationService threw an error at me claiming the SSIN did not match the given birth date. While debugging the ValidationService, I saw the date that was entering the system was 05/31/1900 (23h50m), instead of 06/01/1900 (00h00m). How strange.

To be able to understand the above problem, we need to know how object serialization works in Java. Whenever objects are transfered over a wire, they are serialized. Each object knows how it can serialize and deserialize itself by implementing the private methods writeObject and readObject. The java.util.Date object simply converts itself to a long value while serializing. This long value represents the number of milliseconds since January 1, 1970, 00:00:00 GMT.
For some reason, I don't know why, this long value on Linux is different from the long value on Windows. I can prove this using a simple test. Write a simple test class:

public class Test {
public static void main(java.lang.String[] args) {

System.out.println(new java.util.Date(0,5,1));

System.out.println(new java.util.Date(0,5,1).getTime());

}
}

Now, compile it and run it on Windows, this should be the output (Java 6):

Fri Jun 01 00:00:00 CET 1900
-2195942961000

Do the same on Linux, and this should be the output (Java 6):

Fri Jun 01 00:00:00 CET 1900
-2195942400000


Interesting, isn't it. I wonder if there are other platforms affected as well. I mean, what's the output of the simple class on Mac OS X, BSD, AIX, Solaris, ... . IMHO they should all render the same long value, and I have a sneaking suspicion which platform had an F in mathematics :)

The strange thing is, not all dates are affected. I was doing a batch upload of 600.000+ records, all with different birth dates and SSINs and this was the only one throwing the aforementioned error.

Anyway, the above should be kept in mind when deploying different services talking with each other over RMI, on different platforms. I suspect this is a bug, but who cares. The Date and Calendar stuff in Java is a true nightmare and we all should use joda time instead.