From 7bafc95a7f2804298ddfe75bd35b5234925573aa Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Tue, 13 Sep 2022 12:31:35 +0200 Subject: [PATCH] chore: add load-on-startup configuration for custom Vaadin servlet As of Flow 23.2, Vite dev-server needs VaadinServlet to be initialized before to start. In order to have Vite starting eagerly (before any HTTP request), VaadinServlet must be registered with load-on-startup attribute to a value greater than zero. For custom VaadinServlet this must be done explicitly by the developer. This change updates example code defining custom Vaadin Servlet by adding load-on-startup setting. Part of vaadin/flow#14479 --- articles/advanced/i18n-localization.asciidoc | 5 +++-- articles/configuration/npm-pnpm.asciidoc | 5 +++-- articles/configuration/properties.asciidoc | 4 +++- articles/integrations/embedding/exporter.asciidoc | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/articles/advanced/i18n-localization.asciidoc b/articles/advanced/i18n-localization.asciidoc index 712bd00ca2..6dce1b3c3d 100644 --- a/articles/advanced/i18n-localization.asciidoc +++ b/articles/advanced/i18n-localization.asciidoc @@ -26,8 +26,8 @@ mvn jetty:run -Dvaadin.i18n.provider=com.vaadin.example.ui.TranslationProvider When using the annotation, you could have the servlet class as: [source,java] ---- -@WebServlet(urlPatterns = "/*", name = "slot", asyncSupported = true, initParams = { - @WebInitParam(name = Constants.I18N_PROVIDER, value = "com.vaadin.example.ui.TranslationProvider") }) +@WebServlet(urlPatterns = "/*", name = "slot", asyncSupported = true, loadOnStartup = 1, + initParams = { @WebInitParam(name = Constants.I18N_PROVIDER, value = "com.vaadin.example.ui.TranslationProvider") }) public class ApplicationServlet extends VaadinServlet { } ---- @@ -49,6 +49,7 @@ Or, using the [filename]#web.xml# file: com.vaadin.flow.server.VaadinServlet + 1 i18n.provider diff --git a/articles/configuration/npm-pnpm.asciidoc b/articles/configuration/npm-pnpm.asciidoc index 8c5edf80ae..57fe735c7c 100644 --- a/articles/configuration/npm-pnpm.asciidoc +++ b/articles/configuration/npm-pnpm.asciidoc @@ -65,8 +65,8 @@ Alternatively, you can use the Servlet 3.0 `@WebServlet` annotation: [source,java] ---- -@WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true, initParams = { - @WebInitParam(name = "pnpm.enable", value = "true") }) +@WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true, loadOnStartup = 1, + initParams = { @WebInitParam(name = "pnpm.enable", value = "true") }) public class CustomServlet extends VaadinServlet { } ---- @@ -88,6 +88,7 @@ or use the traditional [filename]#web.xml# file: com.vaadin.flow.server.VaadinServlet + 1 pnpm.enable diff --git a/articles/configuration/properties.asciidoc b/articles/configuration/properties.asciidoc index fe848822df..b9f93ea885 100644 --- a/articles/configuration/properties.asciidoc +++ b/articles/configuration/properties.asciidoc @@ -49,7 +49,8 @@ You can use the Servlet 3.0 `@WebServlet` annotation, which requires you to conf [source,java] ---- -@WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true, initParams = { +@WebServlet(urlPatterns = "/*", name = "myservlet", asyncSupported = true, , loadOnStartup = 1, + initParams = { @WebInitParam(name = "frontend.url.es6", value = "http://mydomain.com/es6/"), @WebInitParam(name = "frontend.url.es5", value = "http://mydomain.com/es5/") }) public class MyServlet extends VaadinServlet { @@ -73,6 +74,7 @@ Yet another approach is to use the [filename]#web.xml# file: com.vaadin.flow.server.VaadinServlet + 1 frontend.url.es6 diff --git a/articles/integrations/embedding/exporter.asciidoc b/articles/integrations/embedding/exporter.asciidoc index 5d58f37e3a..970be27f03 100644 --- a/articles/integrations/embedding/exporter.asciidoc +++ b/articles/integrations/embedding/exporter.asciidoc @@ -166,7 +166,7 @@ public final class UserService { [source,java] ---- -@WebServlet(urlPatterns = { "/vaadin/*" }) +@WebServlet(urlPatterns = { "/vaadin/*" }, asyncSupported = true, loadOnStartup = 1) public class WebComponentVaadinServlet extends VaadinServlet { } ----