Docs

Documentation versions (currently viewingVaadin 14)

You are viewing documentation for an older Vaadin version. View latest documentation

Live Reload

Live Reload works seamlessly in development mode using HotswapAgent for runtime class and resource redefinition. We suggest running your Vaadin project with TravaOpenJDK DCEVM, version 11.0.7+2 or later, which includes HotswapAgent with full Live Reload support. Setup is in most cases as easy as downloading the JDK and configuring your IDE to use it. If you want to know more about the features of HotswapAgent, the documentation in the HotswapAgent webpage is a good resource.

Step-by-Step Guide

  1. Download and unpack the latest version of DCEVM JDK, add the JDK to your IDE, and set your project / run configuration to use it. Alternatively set JAVA_HOME to its location.

  2. In DCEVM 11.0.9 and later, HotswapAgent is disabled by default and needs the JVM parameter -XX:HotswapAgent=fatjar to work with Vaadin. Depending on your project technology stack, you may also want to apply additional configuration.

  3. Using your IDE’s debug command, start the Vaadin application in development mode.

  4. Navigate to a view in your application, edit any Java file in the project, recompile, and the browser will automatically reload the page with the changes.

Additional Configuration

  • HotswapAgent swaps in code changes automatically only when the JVM is running in debug mode. The spring-boot-maven-plugin goal spring-boot:run by default forks a separate JVM without debugger attached, meaning that HotswapAgent will not work. You can disable forked mode by adding <fork>false</fork> to the plugin’s <configuration> section.

  • To hot swap code when the JVM is not in debug mode, you can add the line autoHotswap=true to hotswap-agent.properties (in Spring Boot projects), or add the JVM parameter -javaagent:<JAVA_HOME>/lib/hotswap-agent.jar=autoHotswap=true, where JAVA_HOME is the Java home of the TravaOpenJDK installation. Explicitly enabling automatic hotswapping may also be required with some older IDEs (such as NetBeans).

  • When using the Jetty Maven plugin together with HotswapAgent, ensure automatic restart is disabled (omit or set <scanIntervalSeconds> to a value of 0 or less).

  • The Live Reload quiet time (milliseconds since last Java change before refreshing the browser) can be adjusted with the parameter vaadin.liveReloadQuietTime in hotswap-agent.properties. The default is 1000 ms. Increase this value if you notice the browser refreshing before modified Java files have been fully compiled.

  • IntelliJ IDEA: avoid using the Build project automatically and compiler.automake.allow.when.app.running options simultaneously, since this may trigger automatic reload before classes are hotswapped properly.

Limitations

  • Since the server does not restart, modifications to startup listeners and code that connects frontend and backend components, such as adding a new LitTemplate class, are not reflected. Modifications to routes are, however, picked up.

  • With @PreserveOnRefresh, view instances are reused when reloaded in the browser; hence, hotpatched changes to the view constructor will not be reflected until the view is opened in another browser window or tab.

  • The Vaadin plugin included in the bundled HotswapAgent (1.4.1) does not work with servers that use application class loaders, for instance WildFly, TomEE or Payara. This bug is fixed in a prerelease version of HotswapAgent. To use it, download the JAR and pass the JVM parameter -XX:+DisableHotswapAgent -javaagent:<path/to/hotswap-agent.jar> to replace the bundled HotswapAgent with the fixed version.

E2A0A6FB-1F1D-4867-B591-45DD2FB7985B