Happenings

JDOM ClassCastException

I’ll start by saying that if you’re not a programmer, you’re not going to be interested in this post. You might want to run along and read something better. You probably also want to be a Java programmer.

JDOM is a great Java library for dealing with XML in a reasonably sane way. You turn your XML into an org.jdom.Document object (using a handy utility like SAXBuilder), and then you can use various query and manipulation tools on it. It does, however, have some fairly silly exceptions.

Recently, I was doing some XPath queries as part of a web-app. Like a good developer, I wrote some unit tests so I knew that the XPaths were correct, the XML conversion was correct, etc. I wrote the actual code to implement the test cases and everything worked fine. Great.

Upon deploying the web-app to the container and running it properly, JDOM throws a ClassCastException and says the Document is the cause. Bizarre. After a few checks and no luck , we (I say “we” because there are now a few interested parties) break out the debugger for a look at the running web-app. [Let me stop for a second to say that debugging running web-apps is a triumph of tooling; very useful stuff.] The created Document looks fine, the code steps through ok until… bang. The debugger stops working. Ah.

After a lot of head scratching and googling, we finally figure out the problem: JDOM depends on the Jaxen API for XPath. While our unit test container (actually an IDE) has a reference to a copy of Jaxen for an unrelated reason, the deployment doesn’t. So the problem is one of dependencies.

However, the thing that made this tricky to debug was JDOM throwing an unrelated Exception. A ClassCastException seems completely inappropriate here and helped masked the real cause. A ClassNotFoundException pointing to the Jaxen library would have a) made sense, and b) pointed us at the real cause.

Lessons:

  1. Libraries are only as sane as the most insane thing they do.
  2. Unit tests start falling apart if the environment in which they are run does not match the final environment. This can be a very subtle problem.
  3. Throwing exceptions is only as useful as the quality of the feedback the exception provides.
  4. Debug, debug, debug. If the debugger fails, don’t panic.

Here’s hoping the JDOM guys get rid of that erroneous ClassCastException and switch to something a little more helpful.

N95

I recently decided it was time to upgrade my phone, since my previous phone was starting to fail me in several ways (i.e. the battery was fecked). So I opted for the Nokia N95. (Note: if you’ve ever had my mobile number, it’s still the same. I haven’t changed it since my first phone.)

I had a couple of good reasons for making this choice. First, after my last phone, I’m a big fan of Nokia phones and the Symbian OS. Everything nice I said about my previous phone still applies, but I can now appreciate features like the active desktop style interface a bit more. It had always annoyed me that the screen you get upon unlocking a mobile is near enough useless; basically, a glorified splash screen. Nokia S60 phones are different: switch on active standby and you get 5 icons on your desktop which are shortcuts into your favourite programs (customisable). As well as that, you get the next few events from your calendar displayed clearly and prominently, plus the next items on your to-do list. That’s exactly how it should be, the most important info clearly displayed.

Another major selling point of the N95 is the camera. The previous camera I had was only 1.2 megapixels and performed poorly in all but the best light conditions. My new phone has a 5 megapixel chip, a much better lens, and a two stage auto-focus, which helps the camera pick out the best lighting conditions.

There are plenty of other nice little features (wifi, visual radio, enough oomph for 3D games) but what does it get wrong?

  1. It breaks the Nokia charger standard. Every Nokia phone I’ve ever seen used a standard charger, making it easy to find a spare if you’re away from home. The N95 uses a much slimmer charger. Not good.
  2. The battery life. With great new features, comes great power consumption. If you don’t use the bigger features you get a fairly standard charge for a modern phone (2 days+). If you hammer the features, you could easily wipe it in half a day.
  3. It came with Moby as the standard track. It’s not 1999, and I’m not doing a car advert, thanks.

Other than that, I’m very happy with it. Highly recommended.

Film Fight: August 2007

With this August entry, I’m back up to speed, after the delays for the previous few months.

First up, The Hoax is a strange tale about an author that decided to fake Howard Hughes’ auto-biography while the reclusive billionaire was at his peak. Richard Gere has never been better than here, as the self-interested writer who will do whatever it takes to become huge. As his plan unravels, he keeps digging, coming up with more bizarre solutions. An excellent take on a bizarre idea which is, apparently, true.

No-one was expecting much from a sequel to the family comedy Bruce Almighty, especially with Jim Carrey replaced by the usually more adult Steve Carrell, and Evan Almighty does nothing to beat those expectations. If anything this film is more preachy and less funny than its predecessor. I’m sure kids would lap it up, but there’s little here for the grown-ups.

Finally, to finish Robert Ludlum’s trilogy, The Bourne Ultimatum casts Matt Damon as the man who can weaponise just about anything in his pursuit for the truth, Jason Bourne. The set-up is relatively simple (a journalist is fed information about Bourne, and Bourne works with him to find out how he became what he is), but brings together a number of great action sequences. This, as with the rest of the series, is a masterclass in how to do action sequences; keeping it near the boundaries of plausible while still spectacular enough to warrant viewing. The plot wraps up more neatly than might be expected too.

I’m a little torn this month, but I think The Bourne Ultimatum edges it over The Hoax because there are so few action films that can get away with not having “action” as an excuse for lazy cinema.

Film Fight: July 2007

July’s cinema selection was a fairly mixed bag.

After 12 years of waiting, Die Hard 4.0 finally makes an appearance. You mostly get what you expect with this one: a bunch of action sequences held together by a somewhat ridiculous plot, some over the top villians with questionable motives, and John Mclane killing everyone. You get that all here, but it’s all a bit too ridiculous, too over the top. If you can switch your brain to off, then you can enjoy it. Otherwise, this may be a bit wide of the mark.

Having only seen Glengarry Glen Ross recently, it was a pleasure to see another film by the same playwright, David Mamet. Edmond is about a man who loses his place in the world and goes about trying to find it amongst the seediest parts of New York. Surprisingly dark in tone, this film doesn’t hold back in its vision of the terrible things people can justify to themselves. Superbly shot, with exceptional dialogue, the one caveat being that it’s origins as a play are fairly apparent, Edmond is an excellent film. Highly recommended.

The Simpsons Movie is what most people expected, a long episode of the series. Thankfully, though, it would be an episode from one of the later single-digit seasons. While not as good as the earlier episodes, it doesn’t degenerate as far as the later series which were almost entirely variations on “The Simpsons go to [insert place and vaguely racist jokes here]” or “Homer works as [something stupidly unlikely and unfunny here]”. Although the best joke was spoiled by the trailer, there are still enough set-ups here to make it worth seeing.

Finally, Transformers is Hollywood at its very worst: crass, loud, brainless, and without style. If it had been two hours of robots fighting, I could have gotten behind that. If it had been built-up with any tact, that’d been fine. Instead we’re treated to an episode of Dawson’s Creek, numerous advertisements, some terrible comic relief, and more plot holes than I’ve seen in any other film in recent times. Even the few action sequences on offer are merely perfunctory. I mean, no-one should’ve been expecting a masterpiece here, but if the action scenes aren’t up to much (they’re either mostly off-screen or a blurry mess), then what is the point? The film is almost entirely without merit.

The obvious winner this month is Edmond.

Film Fight: June 2007

June was a bigger month than May for cinema, with 6 films taken in. Let’s get started.

The Hitcher is a remake of the classic Rutger Hauer film about a couple who don’t pick up a hitch-hiker they almost run into. The hiker, the bad guy, then ruthlessly chases across state, murdering anyone who gets in the way. Sadly, it lacks the excellent directorial work of it’s namesake, becoming more of a modern (and by that I mean “dumb”) horror film rather than a taut psychological thriller (with more than enough action). Sean Bean also continues his recent run of terrible performances. Though I can’t really recommend The Hitcher, there is at least one scene that is really quite something to see.

I once said that the big failure of Ocean’s Twelve was that it didn’t really show the heists being perpetrated by the main characters: Ocean’s Thirteen makes me take that back. This time they painstakingly go over every tedious detail of the large scam, spreading some sections way beyond breaking point. Again, this is basically watching an A-list cast mess around on holiday, with a overwritten dialogue and underwritten plot. If you liked the second film, you’ll probably like this.

French thriller Tell No One is about a man whose wife is killed after they have an argument and, seven years later, he spots her on CCTV. From there the investigation reopens, placing him as a suspect, as he tries to understand what’s happening. The director captures every aspect of the story perfectly, from the bitter anger to the overwhelming passions. Beautifully shot and performed, and only marred by a few extraneous scenes and characters, this film is one of the best of the year.

One of the few Asian action films to make it through this year, Exiled is a fairly silly example of the gun play and gangsters genre. Normally the story is just an excuse for some ludicrous action scenes, but here there are nowhere near enough worthwhile action scenes to keep things moving forward. It suffers sorely by tring to be more stylish than it is. A regrettably poor entry.

Owen Wilson tries his hand at the fright game in Vacancy. This is a modern horror film done well, balancing the brutal and gruesome with intense emotional moments and impossible but necessary decisions. The set-up is unsurprising, but the pay offs are of a high enough calibre that it does not matter. Vacancy won’t win any awards, but it’s a fine example of the genre.

Finally, Captivity is pretty much the opposite in terms of the quality of horror it offers. More of an excuse for a bunch of pre-canned set-ups than an attempt to do something that makes sense as a whole, this film fails on a number of levels, not least of all a number of weak performances and a nonsensical plot. If you liked Saw, you might like this (similar style). If not, avoid.

The winner this month was the excellent Tell No One, proving itself to be great in almost every suit.