Saturday, May 5, 2012

Application Skeleton of Vaadin, Spring, JPA and Liferay

I have chance to pick up Vaadin last week, I start with their official tutorial: Address Book Sample. Thanks to Vaadin community created such a great tutorial. The tutorial mainly focus on Vaadin front-end only, this blog post is about integration to Spring technology stack as the back-end that run independent from or in Liferay Portal 6.

The back-end code such as PersonService, PersonRepository and configurations such as persistence.xml, applicationContext.xml, Maven's pom.xml, etc. was generated by Spring Roo. The Spring-Vaadin integration was enabled by Spring Stuff add-on, many thanks to Archie Cobbs created this add-on.

Vaadin Address Book Standalone Sample

Picture above is how the sample look like when it run standalone. You are welcome to fork the code at github, any changes contribute back to the main code base is very much appreciated. Bear in mind that the sample code is far from perfect, but it works. Many works need to be done to become a great application skeleton, you are encourage to look at the outstanding issues, or create one for bug or enhancement.

Edited on 22-Jun-2012: Many thanks to Iwein Fuld for his fixes to enabled the sample run with in-memory HSQLDB instead of MySQL DB.

Vaadin Address Book Sample In Liferay

Picture above is how the sample look like when it run in Liferay. You are welcome to fork the code at liferay branch here.

I hope the sample code is useful to you. I'd love to hear your comments!

Like this blog?

Thanks for visiting! If you like what you see, I'd really appreciate you linking to it or otherwise sharing it with people you think would find it useful.


Chris Jansen said...

Thanks for posting this! I've been using Spring for several years and am now studying Vaadin.

Lim Chee Kin said...

Hi Chris,

You're welcome! I hope the example is useful to you.

Heard of metawidget at

At the moment I am doing a small exercise at, I attempt to shifting all annotation config of metawidget to XML and implement the GORM back-end to the addressbook sample.

Ultimately, I was thinking of building a package where developers only need to specify the Metawidget's XMLs and the system can auto layout a form based on the XMLs.

Would you be interested to work out something together?

Hope to hear from you soon! :)

Best regards,
Chee Kin

Chris Jansen said...

I was actually reading about this morning! I think I need to get up to speed on Vaadin/metawidget before being a good contributor to such a project.

In the project code for your example, I think you need to be using and in memory database, or instruct the developer to install the referenced database locally.

I like your blog thus far too, esp the suggested book section.

Talk to you soon,

Lim Chee Kin said...

Hi Chris,

Thanks for your suggestion, the blog post is updated to include your suggestion.

Take your time, I am new to Vaadin and Metawidget too. I am reading Learning Vaadin at the moment.

Love to hear from you soon!

Chee Kin

Chris Jansen said...

Iwein Fuld commited src to your address book application! That is impressive!!!

Lim Chee Kin said...

Yeah, the blog post is updated to reflect his kindness contribution. :)

Chris Jansen said...

I started reading LEarning Vaadin myself. Am discovering some of the source code used in the book was not included in the book's source code, which may be downloaded. Frustrating!

Lim Chee Kin said...

Yeah, I faced the same issue and file an issue report to the book author at

Unluckily, he didn't gave any solution. I put Vaadin aside at the moment and thinking of resume my learning when Vaadin 7 is release as it have totally different structure compare to Vaadin 6.x

Ozzy said...

Hi, I tried deploying the source in liferay portal server but I cannot make it work, do you have another version to attempt it again?.

Thanks a lot.

Lim Chee Kin said...

Did you installed Vaadin Control Panel Addon to your Liferay Portal? Please see You may need to re-build the WidgetSet to make it work.

For your information, the sample app was built on Vaadin 6.x instead of Vaadin 7.

Hope this help.

Ozzy said...

Hi again, I rebuilt widgetset, but I still have problems, I'm using liferay 6.0.6 and Vaadin 6.8, when I ran mvn package, I generated the war and when I try deploying in the deploy directory the autodeploy start to work but I gave the following message:
INFO: Despliegue del directorio vaadin-addressbook-sample-0.1.0.BUILD-SNAPSHOT de la aplicaci├│n web
24/05/2013 11:16:42 org.apache.catalina.core.StandardContext listenerStart
GRAVE: Error configurando escuchador de aplicaci├│n de clase org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at org.apache.catalina.core.StandardContext.listenerStart(
at org.apache.catalina.core.StandardContext.start(
at org.apache.catalina.core.ContainerBase.addChildInternal(
at org.apache.catalina.core.ContainerBase.addChild(
at org.apache.catalina.core.StandardHost.addChild(
at org.apache.catalina.startup.HostConfig.deployDirectory(
at org.apache.catalina.startup.HostConfig.deployDirectories(
at org.apache.catalina.startup.HostConfig.deployApps(
at org.apache.catalina.startup.HostConfig.check(
at org.apache.catalina.startup.HostConfig.lifecycleEvent(
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(
at org.apache.catalina.core.ContainerBase.backgroundProcess(
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(
at org.apache.catalina.core.ContainerBase$

Thanks again.

Lim Chee Kin said...

Seems like the war file is not package properly as the following error showing SpringFramework's class is not found:
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

This error shouldn't happened unless the Liferay version you used no longer come with SpringFramework.