I’m a big fan of the Wicket framework. Its stateful component-based model, markup inheritance, complete lack of XML and JSP and excellent AJAX support make web development such a great experience.

In a typical Wicket application you use Spring for dependency injection and transaction management, and Hibernate/JPA for data persistence. This makes a powerful stack that powers many successful web applications.

However, when you get used to Wicket you start missing its convention-over-configuration and zero-XML style while working in other layers of the app.

Update: You could use Spring’s JavaConfig and write your application configuration using Java annotations instead of XML, which provides type safety and a pure Java setup.  Still, some developers (me included) feel uncomfortable using Spring just for dependency injection.

Looking for alternatives to Spring, I’ve found that the agile lightweight Guice framework and Wicket play nice together. You can drop Spring and adopt Guice instead, but that leaves your project without transaction management. The missing piece of the puzzle is warp-persist, a transactional framework for Guice created by Dhanji Prasanna. Now you’ve got a complete pure-Java replacement for Spring. The only remaining XML here are the Hibernate mapping files, which are gone if you start using Hibernate Annotations.

Quoting Peter Mularien: “One of the reasons that I think Spring has become so popular in web applications is that there simply hasn’t been another widespread web application stack that (1) is free, (2) is not Java EE, and (3) doesn’t involve JSF”. Well, that’s not true anymore.

Lightweight frameworks like Guice are viable alternatives to Spring. I think the strongest point of a pure-Java solution is that everything is subject to automatic refactorings. You no longer have to mantain your Java code and references to it from XML files in sync. If you are applying agile methodologies, this is a serious reason for considering this stack instead of the more conservative Spring/Hibernate combo.

To get started, read the links below:

  1. http://www.mularien.com/blog/2007/11/28/bleeding-edge-transactional-wicket-web-applications-with-warp-and-guice/
  2. http://richard-wilkinson.co.uk/2008/08/17/more-warped-wicket/

And finally:

Download the quickstart project

Comments and patches welcome.