Maven, Spring, Vaadin and Google AppEngine, Happy Together

In true open source spirit, I scratched my itch. No, not that itch. If you complain about open source projects, you have all the tools at your disposal to fix the problem yourself. Last week, I posted that it’s not straightforward at all to make Spring, Google AppEngine (GAE) and Vaadin work together in Eclipse. This week, I present the solution.

Update: I’ve added a necessary repository to the pom file. So if you had problems previously, please download the file again. Your issues should be solved.

download the pom.xml

It’s a fairly long Maven pom.xml file, but I believe it remains understandable and usable. Using Maven also makes it easier to integrate your project in continuous build systems and to cooperate on a project with other people. The remainder of this post discusses the details, but you can just go ahead and download the pom.xml right away.

In order to get started you should:

  • Adjust the pom.xml to your liking. You probably want to change the artifact and group id’s.
  • Run “mvn clean” to create a clean project with the dependencies in the right location.
  • Run “mvn eclipse:eclipse” to generate the Eclipse configuration files.
  • Import the project into Eclipse (or you can use the m2eclipse Maven integration if you like)
  • Start programming your project. With this configuration you will be able to follow the Spring integration tutorial on the Vaadin site (including the annotation driven configuration, which is my favorite).

If you like to know a little more about what the pom.xml does, here are the various issues that are resolved by it.

Concord Jet
Creative Commons License photo credit: simononly

Google AppEngine

The main issue with Google AppEngine is managing the WAR structure. The Eclipse plugin for GAE cannot directly deploy a .WAR file and it needs a very rigid structure. It takes the contents of the “war” directory and deploys that. The exact directory cannot be changed, neither can the location of the dependencies. So the pom take care of:

  • Java classes are compiled to /war/WEB-INF/classes
  • JAR dependencies are managed in /war/WEB-INF/lib (“mvn clean” both deletes the old jar files and copies the new ones in the directory)

Eclipse project files

The second large block of code you’ll find in the pom.xml is setting up the Eclipse project files:

  • Configuring the various “natures” (those are the different plugins that are enabled for the project)
  • Setting up the environment with, for instance, some additional validators and builders.
  • For all of this to work, you will need to have all the corresponding Eclipse plugins installed (Vaadin plugin, Spring and AspectJ)

As always, this work would not have been possible without the help of a few people. I stand on the shoulders of giants.

There are still a few to-do’s left:

  • Google AppEngine has recently been update from version 1.3.0 to 1.3.1.
  • Maven support inside Eclipse is not yet enabled. I think adding the “org.maven.ide.eclipse.maven2Nature” nature to the pom.xml should solve this, but I haven’t tried it out yet.

download the pom.xml

Good luck and be sure to let me know if you encounter problems or have tips.

(image credit)

  • OneHP


    On mvn clean I'm getting this output…

    [INFO] ——————————————————
    [INFO] ——————————————————
    [INFO] Failed to resolve artifact.


    Try downloading the file manually from the project website.

    Tried bumping the version number up to 1.3.1 in the properties but that seems to make it worse (more errors).
    Any ideas? Want the full Maven output?

  • It looks like there's a repository missing. I probably already downloaded the dependencies at some point. If you add the mvnsearch repo it should work:
    <name>Maven search repository</name>

    I can't test it right now, but I'll try it out tomorrow and update the pom to reflect the change.

  • OneHP

    That worked great thanks. Not got time to do the Vaadin tutorial at the moment but I'll let you know how it goes.

  • Great to hear it's working now. I have updated the downloadable pom file to reflect this change.

  • Pingback: Google AppEngine, Vaadin, Spring, a Match Not Made in Heaven()

  • Pingback: 9 of my Best Posts On Java, a Streamhead Anthology()

  • Pingback: Storing and Obtaining Services and Repositories in Vaadin()

  • Pingback: Java Client for Google Data API, One More Step to World Domination()

  • Roger Parkinson

    In your earlier post on this when you introduced Maven it sounded like it was the only choice. There is also Ivy which plays well with Eclipse and Spring.

  • You're correct. Ivy is a great tool if you only want to do dependency management. You do have to combine it with some build toold (Ant, Gradle, maybe others). But I must confess its simplicity attracts me.

  • Slscripters

    Hi, do you have a solution for developing vaadin + spring + maven + googleappengine without using eclipse?

  • Dimitrisli

    Great article, spot on what I was looking for!

    I have 'mvn clean' and 'mvn package' successfully from inside eclipse using m2eclipse. Now I am trying to run as a web application from the eclipse 'run configurations'. But I am getting the following:

    Exception in thread “main” java.lang.NoClassDefFoundError: com/google/appengine/tools/development/DevAppServerMain
    Caused by: java.lang.ClassNotFoundException:
    at Method)
    at java.lang.ClassLoader.loadClass(
    at sun.misc.Launcher$AppClassLoader.loadClass(
    at java.lang.ClassLoader.loadClass(

  • What's the main driver for using Maven here?

    If you're in Eclipse anyway what's wrong with simply using the GAE plugin to create your project. As for managing dependencies, you know what those dependencies are, so just download them and put the jars in the WEB-INF/lib folder.

    Maven just seems to add a lot of pain and fuzziness (to a lot of projects, not just this), so what am I missing?

  • Asdf

    Obviously you can do everything by hand if you want to. You can hand-compile your project to java bytecode if you want.

    If maven was an absolute necessity, then it would be included in gae, but it's not. However, it adds many nice features including the ones mentioned in his post.

    I think this pom.xml is really nice and sweet. Thanks!

  • In all honesty, I've been asking myself that same question. There is a lot of overhead associated with creating the Maven pom (but the maintenance is not that bad).
    There are a number of advantages: first it manages transitive dependencies, if I upgrade a library, I don't have to think about upgrading that libraries dependencies.
    Second, it's easy to have a portable project. If I want to involve other developers, I can just give them the project and they're good to go. It doesn't matter whether they use Eclipse or not.
    And finally, it creates a reproducible build, ideally suited for continuous builds and integration. Something which I'm not doing right now, but I envision I might at some point.
    But you're absolutely right when it comes to small, one-off projects, you might not want to bother and just go ahead and put everything in Eclipse.

  • I pretty much agree with Peter’s reply: I want to have a repeateable & portable (not necessarily between IDEs but between developers ) build. I want to be able to build it externally using a CI tool (hudson FTW!) and possibly measure code metrics w/ Sonar.

    This said, I just threw out maven to move forward but I’m pretty sure I’ll regret it on the long run. I also think I’ll reconsider several times…

  • Pingback: Launching my First Vaadin AppEngine Project()

  • Pingback: Vuosi lähestyy loppuaan – Scalaa ja App Engineä ;) « Spagettikoodi()

  • Pingback: server encountered an internal error () - Forum -