Java Pet Store 2.0 – a Java EE5 based, Web 2.0 style, mashup example

If you’ve been around for a while then you’ll remember seeing or hearing about the ‘Java Pet Store’ example application that Sun put together to illustrate how to build a Java EE technology (then J2EE) together with best practice patterns.

The latest version of the Java Pet Store is now available on the java.sun.com website. It has been redesigned and built using latest Java EE5 technologies, for example JSF and Java Persistence API, but also incorporates many ‘Web 2.0’ typical features. For example, the web app now features extensive use of AJAX, RSS feeds, and also integrates with Google Maps (apps integrating in this style with other websites are commonly called a ‘mash-up’).

applicationContext.xml file replaced after Grails upgrade

If you have heavily modified your applicationContext.xml file for your application, make sure you take a copy of it (your whole app to be safe) before you upgrade to a newer version of Grails, since during the ‘grails clean’ and ‘grails upgrade’ steps the applicationContent.xml file will be replaced.

Progress with Grails this week – found some bugs, worked out some issues

I haven’t worked on my Grails project (an Online Store example application) for a few weeks, but I had a couple of days off work this week so spent a number of hours working on some new features.

I found an issue with the pagination support when using results sorted in reverse id order and logged bug GRAILS-914.

I also came across an issue that I couldn’t work out – I had some error in one of my Controllers but the problem was being masked by the error.jsp page not functioning correctly. It looks like this was fixed in GRAILS-365 in 0.3, but I was still seeing this issue in 0.3.1. I logged a new bug report for it (GRAILS-919), and decided to upgrade to 0.4.2 at the same time.

After upgrading to both Groovy 1.0 and Grails 0.4.2 (running ‘grails clean’ and ‘grails upgrade’ on my existing app), I found a number of things I needed to change in my existing code, which I captured as separate posts here:

  1. @Property annotation removed
  2. Domain class constraint ‘length’ deprecated in Grails 0.4.2

Plus a couple of other helpful tips:

  1. Changing the default list method
  2. Linking to other actions from a view page
  3. Using pagination with Controller action other than the default list

Domain class constraint ‘length’ deprecated in Grails 0.4.2

The domain class constraint ‘length’ has been deprecated in Grails 0.4.2, and needs to be replaced with the equivalent constraint ‘size’ instead.

If you have upgraded to 0.4.2 you may see this error on startup:

<code>Domain class [class ExampleDomain] includes the length constraint for the exampleProperty
 property.  This constraint is deprecated and will be removed in the future.  
Please update your code to use the size constraint instead.
</code>