Vaadin Grails Plugin

Hi All,
I finally tried integrating Vaadin with Grails to see if it was possible to develop a Vaadin application without having to constantly redeploy in order to see my progress. The result is a new Vaadin Grails plugin, and I was very impressed with the increase in productivity. For details, check out the plugin
, or install the it in your Grails app like this:

grails install-plugin vaadin

Have fun!


Great work Daniel!

Added a short notice about it on the wiki:

Thanks Henry


Can you post a simple Hello World on integrating Vaadin and Grails using your plugin?

Also, what are your plans for maintaining the plugin, going forward … as new versions of Vaadin and Grails become available?


Hi Joe,
My original plans for the plugin were dependent on the response that it received. Recently a few people have requested information about the plugin, so I’ve decided to actively maintain it, starting this week. You can track my progress, or vote for features or issues for the plugin
on its Codehaus JIRA page
. My first priority is to update the plugin to the latest version of Vaadin. After that, I plan to write a Hello World example and post it
on the wiki here
. Hopefully that will be some time this week.


Hi Daniel,

I tried Vaadin Grails Plugin but I get following exception when accessing a one-to-one|many mapped relation in Vaadin application. Did you ran into same issue? Are there any workarounds? It may be related to but I’m not sure. Thanks!


java.lang.RuntimeException: javax.servlet.ServletException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
at com.opensymphony.sitemesh.webapp.decorator.BaseWebAppDecorator.render(
at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(
at org.springframework.web.filter.OncePerRequestFilter.doFilter(

Hi Michael,
I’ve not come across the problem you’re describing while working with Vaadin in Grails. I have come across the same error in other applications though. Usually I’ve been able to fix them by changing the relationship to use eager loading instead of lazy loading, or accessing the collection that defines the relationship while the Hibernate session is still open.


Hi Joe,
I just posted a simple Hello World application to the wiki
that uses the current version of the plugin. I’ve added some extra features to the plugin over the past week, and I’ll be releasing it as soon as I get the chance to test it properly.

Hi Daniel,

Thank you for the Vaadin Grails plugin and an overall great tutorial. It is really cool way to enable the developer to write Vaadin apps with Groovy. I do however have some problems using e.g. Button events within the Groovy/Vaadin setup. Is there anyway for you to extend the Hello World example and show how to use events within Groovy/Vaadin?

Kind regards,



and foremost, thanks for providing the grails plugin.

However, I have a somewhat trivial newb question, which relates more to grails than Vaadin, though. How do you inject a grails service so that it can used in the Vaadin Application class?

A simple:

class MyApplication extends Application {
   def someService


doesn’t seem to work. someService is null when I call it. Any ideas how to solve this?

Nevermind, I found a solution for this. I’ll share it, as this might save someone a minute or two.

You can get a handle to your service, for example, by using a factory class like this:

import org.codehaus.groovy.grails.commons.ApplicationHolder

class ServiceFactory {

    def getSomeService() {
        return this.getBean('someService')

    private def getBean(beanName) {
        return ApplicationHolder.getApplication().getMainContext().getBean(beanName)


Then you would use this class in a vaadin component, like this:

def serviceFactory = new ServiceFactory()
def service = serviceFactory.getSomeService()

Vaadin plugin is already working but I want to access grails controllers from the browser?
how can we access grails domain objects or controllers like the (index,list,etc…) ?

Hi Daniel,

How can we change the URL mapping on Vaadin application so that I could access grails controller in the browser.

Actually I could now access grails controllers and vaadin application in the browser by changing the url mapping
in VaadinGrailsPlugin.groovy from “/" into "/VAADIN/”.

If I change it to other pattern like “/MainApp/" , I get widgetset not loaded error. It only works on this pattern ("/VAADIN/”).

def servletMappings = webXml.“servlet-mapping”
servletMappings[servletMappings.size() - 1]

  • {
    “servlet-mapping” {


Is there other way I could change this pattern (“/VAADIN/*”) to access grails controller and access vaadin application


nat nat

I used your modifications to the plugin as a starting point, with the following changes:

  1. Update the web.xml generation to set the URL mapping from a config property, instead of always using “/*” (otherwise it won’t play well with Grails controllers; it prevents you from ever seeing them).
  2. Added another url mapping using the vaadin servlet to the URL pattern “/VAADIN/*”. Without this, you can never reach the widgetset URLs and your Vaadin app won’t run.

Hope that helps!

What are the class I need to change or update? or do have a any code sample or a script we could follow?


Thank you very much Daniel,
VGrails framework uses your plugin in a very intensive way :slight_smile:

@West Java, Indonesia

It’s the VaadinGrailsPlugin.groovy file that has to change, which is what manipulates the web.xml. Here’s a snippet of the main change, though I also modified the logging block under “getConfig” to show the currently configured urlValue.

        def vaadinApplicationClass = config.applicationClass
        def vaadinProductionMode = config.productionMode
		def vaadinUrlPattern = config.urlPattern
        def contextParams = webXml."context-param"
        contextParams[contextParams.size() - 1]
 +  {
                        "context-param" {
                            "description"("Vaadin production mode")

        def servlets = webXml."servlet"
        servlets[servlets.size() - 1]
 +  {
                    "servlet" {
                            "init-param" {
                                    "description"("Vaadin application class to start")

        def servletMappings = webXml."servlet-mapping"
        servletMappings[servletMappings.size() - 1]
 + {
                    "servlet-mapping" {
                    "servlet-mapping" {

Server running. Browse to http://localhost:8090/hello-vaadin
Compiling 1 source file to
Compiling 2 source files to
Deleting directory C:\Documents and
2. When I load the page in browser, the page is sometimes unavailable
(error 503).
Maybe this has something to do with the first problem.
Has anyone seen the same problem?

Hey Abiel,
Thanks for the feedback :slight_smile: . I’m glad it’s been useful for you. Congratulations on VGrails: it looks great!