Adam Bien's Weblog

Essential Vaadin 7 / Java EE Maven 3 POM

With an additional Maven 3 dependency and three dependencies in total, you can integrate Vaadin 7 with your Java EE 6/7 backend in an efficient way. No XML configuration or any other configuration is needed.

With the cdi-integration you can not only inject EJBs and CDI managed beans directly to the UIs and views, but also expose the view with a single annotation:

import com.vaadin.cdi.CDIUI;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import javax.inject.Inject;

public class WelcomePage extends UI {

    ReceptionService service;

    protected void init(VaadinRequest request) {
        String message = service.welcome();
        Label label = new Label(message);
        setContent(new HorizontalLayout(label));

public class ReceptionService {

    public String welcome() {
        return "Hello, Developer! No XML, No Configuration, and it works!";

The pom.xml is based on a minimalistic Java EE template enhanced with three additional dependencies to Vaadin mentioned before:

<project xmlns="" xmlns:xsi=""



A deployable Java EE project was pushed into

See you at Java EE Workshops at MUC Airport (particularly at JavaEE UI workshop)!

NEW dates, new workshop: Java EE 7 Workshops: Bootstrap, Effective, Architectures, JavaScript Bootstrap and HTML 5 December, 7th-11th
NEW: Effective Java EE 7 -- Available For Streaming


A book about rethinking Java EE Patterns


Any reference where to put @WebServlet annotation with this? Thanks.

Posted by Angga on May 13, 2013 at 03:15 PM CEST #


you don't need any reference to a @Servlet. It should just work out-of-the-box,



Posted by Adam Bien on May 14, 2013 at 11:25 AM CEST #

Hi Adam,

Yap I understand, lets say I want to configure url pattern or maybe JEE security, etc through @WebServlet. Should I just use the web.xml then? Thanks.

Posted by Angga on May 14, 2013 at 09:08 PM CEST #

Hey Adam

I love your minimalistic style! :)

The snippet above didn't work on my glassfish 3.1, unless i've put an empty beans.xml in webapp/WEB-INF/ directory. Then it works great :)

I guess for JEE-7 we'd also need the bean-discovery-mode=all flag in the beans.xml

Posted by Raffi on October 07, 2013 at 05:08 PM CEST #


Vaadin-CDI is pulling vaadin-* 7.0.2. I can get it to work with 7.1.6 by manually specifying the dependencies, but the beauty is lost.

Is the only way to wait for a non-alpha vaadin-cdi?


Posted by zemiak on October 08, 2013 at 08:59 PM CEST #

Hi Adam,

I would like know your opinion on Vaadin vs. JavaFX. I am especially backhand programmer and I would like to learn one of these frontend technologies. Can you tell me how you feel the comparison of these technologies? Thanks and I appreciate your work on this blog :)

Ciao Petr

Posted by PBouda on November 02, 2013 at 10:58 AM CET #

When I checkout, build and deploy this in Wildfly 8, i get the error "failed to load bootstrap javascript VAADIN/vaadinBootstrap.js"

Any idea what I could be doing wrong?

Posted by Edem on February 25, 2014 at 06:57 PM CET #


Adam, thanks, everything work just fine!

Edem, you just need to specify session tracking mode for vaadin app through @WebListener:

public class ServletContextListenerImpl implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {

public void contextDestroyed(ServletContextEvent sce) { }

or web.xml:

<web-app xmlns=""

Posted by Bogdan on July 20, 2014 at 07:41 PM CEST #

Hi Adam,

I tried out your example and it worked very well. However, when trying to add something simple like a new theme to add my own CSS for layout purposes, things went out of control. As it stands this example, while fully functional and very clear, is not enough to make a simple application from. Perhaps it's a good idea to work on an addition that allows stuff like theming without having to add the overhead of stuff like custom widgetsets.

Posted by Dieter on September 10, 2015 at 09:54 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
Online Workshops
...the last 150 posts
...the last 10 comments