Documentation

Documentation versions (currently viewingVaadin 23)
New Acceleration Kits: Observability Kit, SSO Kit, and Swing Kit. Read the blog post.

Live Reload

This page demonstrates how to enable hotswap when developing Vaadin applications using CDI (Context and Dependency Injection,the standard dependency injection framework for Java EE).

Apache TomEE

You should use Apache TomEE with the tomee-maven-plugin, and start the server by running the goal tomee:run. Configure the plugin as follows in the <plugins> section of pom.xml:

<plugins>
    <plugin>
        <groupId>org.apache.tomee.maven</groupId>
        <artifactId>tomee-maven-plugin</artifactId>
        <version>7.1.1</version>
        <configuration>
            <tomeeClassifier>webprofile</tomeeClassifier>
            <context>ROOT</context>
            <synchronization>
                <extensions>
                    <extension>.class</extension>
                </extensions>
            </synchronization>
            <reloadOnUpdate>true</reloadOnUpdate>
            <systemVariables>
                <openejb.system.apps>true</openejb.system.apps>
                <tomee.serialization.class.blacklist>-</tomee.serialization.class.blacklist>
            </systemVariables>
        </configuration>
    </plugin>

    <!-- more plugins -->
</plugins>

The configuration enables auto-reload and ensures that any change to a file with the extension .class (a Java recompile) triggers the TomEE server reload. You still need to refresh the browser page. If you base your project on the Vaadin CDI starter (from https://vaadin.com/hello-world-starters), the above configuration is already done for you.

During the hotswap cycle, the session is serialized before the server is stopped and deserialized after it’s restarted. This means that the user log-in and other session-based data are still available.

Known Issues

  • During hotswap, the TomEE log may contain warnings about memory leaks due to the webpack server and watchdog process not being terminated. These can safely be ignored.

  • If a class with a @Route annotation is removed, the route given in the annotation is still navigable after reload. This isn’t a problem when only modifying the route of a view, without deleting the Java class.

Other Servlet Containers

Other popular CDI-enabled servlet containers include WildFly, JBoss Enterprise Application Platform (EAP), GlassFish, IBM WebSphere and Oracle WebLogic. Some of these come with IDE integrations that enable hot reloading of application code. If you develop a Vaadin application against one of these application servers, consult the provider for available developer tooling.

46D369C8-D013-4CCA-9D7B-246A49ADAE97