← Back

Embed for Vaadin

Run your Vaadin applications in an embedded server




Embed for Vaadin is a library allowing you to quickly initialize Vaadin from your IDE. It provides an easy-to-use API to initialize an embed Tomcat container running a particular component or Vaadin application.

The API also allows you to open the default browser automatically and allocates an available HTTP port if none is provided. The API is extensible so that you can suit it you to your own needs.

This add-on works best when used with a build tool such as Maven as it requires Tomcat to operate. Make sure to add this dependency in scope "test" or make it optional such as these libraries do not get transmitted in your project. The add-on is available on the central repository so you don't need to configure an extra repository for it.

To use this add-on with Vaadin 6, please use:

com.bsb.common.vaadin com.bsb.common.vaadin.embed 0.5

For Vaadin 7, please use:

com.bsb.common.vaadin com.bsb.common.vaadin7.embed 0.6

There is also a simple archetype to quickly get you started. For more information, have look to the documentation.

Sample code

public static void main(String[] args) {

 * A simple {@link EmbedVaadinServer} builder that adds Spring integration.
 * <p/>
 * Assumes that the application is deployed with a web application root
 * directory holding a Spring <tt>ApplicationContext</tt> at the default
 * location.
public class CustomEmbedVaadin extends EmbedVaadinServerBuilder<CustomEmbedVaadin, EmbedVaadinServer> {

    private EmbedVaadinConfig config;
    private final String beanName;

    private CustomEmbedVaadin(String beanName) {
        this.beanName = beanName;

     * Creates a new instance to manage a vaadin {@link com.vaadin.Application} defined by the
     * specified <tt>Spring</tt> bean.
     * <p/>
     * A root context directory must be specified holding the default application application
     * context to load, i.e. <tt>WEB-INF/applicationContext.xml</tt>
     * @param beanName the name of the spring bean
     * @return an instance handling that application
    public static CustomEmbedVaadin forSpringBean(String beanName) {
        return new CustomEmbedVaadin(beanName);

    protected CustomEmbedVaadin self() {
        return this;

    public CustomEmbedVaadin withConfigProperties(Properties properties) {
        // We are happy with the default configuration but we could create our own here if needed
        this.config = new EmbedVaadinConfig(properties);
        return self();

    protected EmbedVaadinConfig getConfig() {
        return config;

    public EmbedVaadinServer build() {
        return new EmbedVaadinWithSpring(getConfig(), beanName);

     * An {@link EmbedVaadinServer} implementation that starts and use
     * Spring behind the scene.
    private static class EmbedVaadinWithSpring extends AbstractEmbedVaadinTomcat {

        private final String beanName;

        private EmbedVaadinWithSpring(EmbedVaadinConfig config, String beanName) {
            this.beanName = beanName;

        protected void configure() {

            // Setup vaadin servlet - the SpringAwareApplicationServlet is an extension that takes
            // the name of a Spring bean to initialize a new application
            final Wrapper wrapper = initializeVaadinServlet(new SpringAwareApplicationServlet());
            wrapper.addInitParameter("applicationBean", beanName);

            // Make sure Spring starts - this basically add an extra listener to the webapp
import com.vaadin.ui.Button;

 * Example main class launching a server and starting the browser.
public class SampleMain {

    public static void main(String[] args) {
        EmbedVaadin.forComponent(new Button("Hello")).openBrowser(true).start();


(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.


#15: Fixed development header that was enabled by default while doc states it is optional #14: Updated to Tomcat 7.0.32 #13: Updated to Vaadin 7 beta3 #11: Updated to Vaadin 7 beta2 #10: Updated to Vaadin 6.8.0. Work around a binary incompatible change made in that Vaadin version

Apache License 2.0


Vaadin 6.8+
Vaadin 7.0+
Vaadin 6.2+ in 0.1
Vaadin 7.1+ in 0.6
Browser Independent

Vaadin Add-on Directory

Find open-source widgets, add-ons, themes, and integrations for your Vaadin application. Vaadin Add-on Directory
The channel for finding, promoting, and distributing Vaadin add-ons.