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.

12 comments:

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 http://metawidget.org/?

At the moment I am doing a small exercise at https://github.com/limcheekin/grails-metawidget-vaadin-addressbook, 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 metawidget.org 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,
Chris

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!

Cheers,
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 https://github.com/nfrankel/More-Vaadin/issues/2

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.
Pablo

Lim Chee Kin said...

Did you installed Vaadin Control Panel Addon to your Liferay Portal? Please see https://vaadin.com/web/sami/liferay. 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(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4078)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1345)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:619)

Thanks again.
Pablo

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.