Sam Newman's site, a Consultant at ThoughtWorks

Archive for ‘November, 2003’

Well, I managed to get “JBoss”: and “MySQL”: working thanks to a kind friend who dug his config files out. Getting “Hibernate”: and JBoss working together was fairly simple, although I hate the fact that the Hibernate libraries have to be stuck in JBoss’s own lib directory thanks to one of its infamous class loader problems that never seem to get fixed. A minor hiccup was when JBoss forced the MySQL driver into an auto commit mode which it doesn’t support (this is despite MySQL’s own driver defaulting to false), although passing in a parameter to the JDBC URL fixed that.

Throughout the whole process I’ve found Hibernate very user friendly – the error messages are informative and helpful, which is more than can be said for JBoss and Tomcat. Next up I’m going to create a sample object model with some one to many relationships with both Hibernate and as Entity beans, to get a rough idea of performance.

“Hibernate”:, as you may or may not be aware is a persistence engine for Java. As such it is by no means unique – it joins the ranks of JDO, Java Serialisation and the persistence features of the EJB specification as another option in an already crowded market. Good overviews on Hibernate can be found at the “official site(Hibernate and Tomcat Quickstart)”: and in an article over at “The ServerSide(The ServerSide – Introduction To Hibernate)”:

I like several things about Hibernate. Firstly it seems a lot quicker to develop than EJBs are.The classes you want to persist don’t need stub classes, or special interfaces – they are just normal beans. So not only can you quickly create these classes using code generation tools already in most modern Ode’s, but the beans themselves are abstracted from the method of persistence being used. Hibernate even ships with a tool to generate these classes from your mapping files, which is handy when used as part of an Ant build. Next, the definition of relationships is fairly easy – as is implementing lazy loading. The fact that you have to keep a Hibernate session if you want to use lazy loading of relationships is a pain but understandable.

The mapping files (which define the relationships between beans to be persisted and the datasource) is very straightforward, and as another nice touch Hibernate can read your mapping files and automatically create and keep in sync the database tables – again a great feature as part of a development build and deployment.

The reduced development overhead compared to EJB development coupled with the apparent performance improvements over simple untuned EJB applications means that I may find myself using this more and more. This weekend I’ll try and get a Hibernate-JBoss install working to carry out some simple performance comparisons between an EJB-based persistence and Hibernate based persistence.

Finally, after much cursing, shouting, drinking and general annoyance, I have managed to deploy a sample “Hibernate”: application. I must point out here that the problems I had have nothing to do with Hibernate – the documentation is excellent, although their sample application could be packaged a little better (you know, to actually produce a WAR file). The problem I had was with “Tomcat”:

Up to this point I have been using “Jetty”:, because it just WORKS. It doesn’t have fancy web-based admin consoles or more config files than you cna shake a stick at, you just put your WAR file in its webapps directory, and restart. At which point it deploys your webapp. Tomcat however doesn’t do that – oh no. Sometimes it ignores your WAR file. Othertimes it unpacks it, but if it does it won’t update this unpacked directory structure if the WAR file changes even if you restart Tomcat. So now my build process has to delete directory structures under Tomcat (I’m sorry, but I am not going to start dealing with unpacked WAR structures – that way madness lies). Oh, and guess what? When Tomcat has an error with a web.xml, it doesn’t tell you which webapp it found the file in! Isn’t that cool! “Now if Jetty was so good, why are you using Tomcat?” you may ask Well, this may be lazyness on my part but the example application had the tomcat config settings and I didn’t feel like working out the equivelent Jetty settings (why can’t these things be standardised?).

Up to then things had gone well – I got “MySQL”: installed and running as a service quite quickly. After finally getting the Hibernate example working I had a quick look at getting Hibernate and JBoss working together, but hit the problem that I couldn’t find any documentation explaining how to get “JBoss”: working with MySQL – that excersie can wait for another day. Anyway, expect a brief writeup on Hibernate tomorrow – I must say that from what I’ve seen already it looks excellent.

I’ve discovered a variety of solutions for providing rich UI controls for web-based applications of late:

* As mentioned before, the “Display Tag Library”: provides a JSP custom tag lib for producing CSS-styled tables with sorting, grouping, paging and various export formats. Its easy to use and works well, although could do with some updates to work better with the JSTL and JSP Expression Language.
* “Stuart Langridge’s”: “DHTML sortable tables”: provide a client-side solution to sortable tables – it doesn’t offer as many features as the Display Tag Library but is very easy to use and is great if you can’t rely on server side software, or even if you can but can’t use taglibs
* Via “Zeldman”:, “Brainjar(Brainjar – Revenge of the Menu Bar Demo)”: has some very good looking DHTML drop down menus
* Common Controls provide a set of commercial Tag libraries that integrate with struts to produce some very nice looking controls. The fact that they integrate with Struts is a big plus – one of the problems with the Display Tag Library is that it doesn’t integrate with struts too well. The big problem is that they want a per-server license AND developer licenses. Its not too expensive if you only have one developer and one server, but if you are deploying several servers (as some of my friends are) it can soon get quite expensive. If they offered a flat-fee rate I’d be more interested.
* The “struts menu”: is an open source project that as you’d expect gives you nice menus, but isn’t tied to struts any more. Some of the menus it produced did cause problems under firebird however.

Finally got around to adding a search to the site – I’ll be adding an advanced search feature as soon as I get my head around the tags. Yell if there are any problems!

Right now, I am supposed to be on my way to seeing the “Flaming Lips”:, one of the best live bands on the planet, at the “Hammersmith Apollo”: Instead, I am trying to work out why one of our warehouse management systems stopped working, and why even after I’ve cobbled together a fix for a problem I don’t understand won’t it accept a file its been accepting quite happily for the last couple of months. An even bigger problem is that I don’t have the file the file in question to hand – its being emailed to me as we speak. So I’m just sitting around, waiting for the ruddy file to arrive, which inevitably will of been mangled by someone at the warehouse…oh well…

_Updated 7:29pm_: Well, finally got the email at the second attempt, everythings sorted so now its time for a mad dash across London to try and get to the concert in time….who wants a bet that the underground will get flooded or something?

So there I was, trying to create an XSLT style sheet for my RSS 2.0 feed, when I managed to overwrite the main index.html template for my blog with the RSS 2.0 template. Thankfully a friend pointed out than I’d made a right asshat of myself – I’ve restored and earlier version of the template in the meantime, as I won’t have time to fix it properly until tomorrow, as I’m off to see the Flaming Lips tonight…