flow-and-components-documentation
flow-and-components-documentation copied to clipboard
v14 compatibility mode documentation is incomplete for Embedded Jetty or similar (w/fix)
Description Migration instructions are incomplete for Embedded servers.
Reproduce with:
- Use a working application using embedded Jetty (v13 or earlier) -- for example the Vaadin Tutorial https://vaadin.com/tutorials/embedded-jetty-server-in-vaadin-flow
- Change vaadin version to v14.0.2
- Add the
flow-server-compatibility-modedependency to pom.xml - Run the Main method as a Java application
Expected behaviour: The application should run in Bower compatibility mode, and not produce an error.
Actual Behaviour Under embedded Jetty, the application crashes with
Caused by: java.lang.IllegalStateException: Unable to determine mode of operation. To use npm mode, ensure 'flow-build-info.json' exists on the classpath. With Maven, this is handled by the 'prepare-frontend' goal. To use compatibility mode, add the 'flow-server-compatibility-mode' dependency. If using Vaadin with Spring Boot, instead set the property 'vaadin.compatibilityMode' to 'true' in 'application.properties'.
at com.vaadin.flow.server.DefaultDeploymentConfiguration.checkCompatibilityMode(DefaultDeploymentConfiguration.java:270)
Fix After reading the error message and searching in the source, stumbled upon the notes for Spring Boot and decided to try the same approach -- define a property before launching the embedded server.
System.setProperty("vaadin.compatibilityMode", "true");
Other missing information
Note that https://vaadin.com/docs/v14/flow/advanced/tutorial-all-vaadin-properties.html only mentions the vaadin. prefix for SpringBoot, but it is required for all instances where -D or setProperty is used, non only SpringBoot.
Same thing for the migration guide. https://vaadin.com/docs/v14/flow/v14-migration/v14-migration-guide.html
Versions: - Vaadin / Flow 14.0.2 - OpenJdk 8 - Windows 10
This most likely happens because the embedded Jetty doesn't consider the web fragment defined by flow-server-compatibility-mode. I would guess that this is caused by setConfigurationDiscovered(true);.
It would indeed be good to somehow clarify the documentation, but I'm not sure exactly how that should be done since each embedding case is unique.
Setting a system property is not a universal solution since it affects the whole JVM. In most cases you only have one application running in the same JVM with this embedding approach, but that's not universally true.
Note that setting a system property is also the approach for the i18n translator.
It is difficult to set servlet initparameters.
I believe that having a config properties file on the classpath would be cleaner and allow a more universal solution, as it could also be kept under version control in one place as opposed to scattered in several files -- currently there is a mix of environment variables, servlet parameters, class overrides and system properties to make a solution work locally, embedded and on the various clouds.
Le mar. 27 août 2019 à 02:21, Leif Åstrand [email protected] a écrit :
This most likely happens because the embedded Jetty doesn't consider the web fragment defined by flow-server-compatibility-mode. I would guess that this is caused by setConfigurationDiscovered(true);.
It would indeed be good to somehow clarify the documentation, but I'm not sure exactly how that should be done since each embedding case is unique.
Setting a system property is not a universal solution since it affects the whole JVM. In most cases you only have one application running in the same JVM with this embedding approach, but that's not universally true.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/6327?email_source=notifications&email_token=AAFFWB634YBEPMNH3RCQUW3QGTBVPA5CNFSM4IPZZXQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5GUAJY#issuecomment-525156391, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFFWB3ASM6OYUEYDQGZXGDQGTBVPANCNFSM4IPZZXQQ .