Repository navigation
Closed
Labels
DXImpact: HighReleased with Vaadin 23.1.6Severity: Minorbugdevelopment modepwaviteTickets related to vite supportTickets related to vite support
Description
Description of the bug
If the @PWA is used on the AppShell class, the project fails to start when using Vite with the following error (in dev mode):
java.lang.NullPointerException: Cannot invoke "javax.servlet.ServletConfig.getServletContext()" because the return value of "javax.servlet.GenericServlet.getServletConfig()" is null
javax.servlet.GenericServlet.getServletContext(GenericServlet.java:123)
java.base/java.util.Optional.map(Optional.java:260)
com.vaadin.flow.server.VaadinServletService.getPwaRegistry(VaadinServletService.java:232)
com.vaadin.flow.server.BootstrapHandler.setupPwa(BootstrapHandler.java:1741)
com.vaadin.flow.server.communication.IndexHtmlRequestHandler.synchronizedHandleRequest(IndexHtmlRequestHandler.java:124)
com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1564)
com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:299)
com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:106)
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:141)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
When the above error is shown in the browser (and it is also visible in the console), then it will work after the browser is refreshed.
It works fine in Production mode with Vite.
It works fine in dev mode as well as production mode when using webpack.
This problem is not happening in 23.1.0.
Expected behavior
The application should start normally in dev mode the first time it is loaded in the browser, not just after failing once and reloading the browser.
Minimal reproducible example
- Download the default base project from start.vaadin.com with 23.2 (Pre) as the platform version
- Run the project via the main class or
mvn spring-boot:run
Versions
- Vaadin / Flow version: 23.2.0.alpha1
- Java version: 17
- OS version: macOS
- Browser version (if applicable): N/A
- Application Server (if applicable): N/A
- IDE (if applicable): N/A
Metadata
Metadata
Assignees
Labels
DXImpact: HighReleased with Vaadin 23.1.6Severity: Minorbugdevelopment modepwaviteTickets related to vite supportTickets related to vite support
Activity
[-]PiT 23.2: spring-boot based project fails to start in dev-mode when @PWA is present [/-][+]PiT 23.2: spring-boot based project fails to start in dev-mode when using Vite and @PWA[/+]simasch commentedon Jul 7, 2022
I have the same issue with 23.1.2
mshabarov commentedon Jul 27, 2022
The same issue replicates with V23.2.0.alpha3, but never replicates with V23.2.0.alpha3 + Flow 23.2-SNAPSHOT (which has a bunch of fixes for service worker handling with Vite).
mshabarov commentedon Jul 28, 2022
Also replicates with 23.1.3, but doesn't replicate with Flow 23.2-SNAPSHOT patched with #14229.
fix: build the service worker without writing it to FS (#14182) (#14229)
vaadin-bot commentedon Aug 9, 2022
This ticket/PR has been released with Vaadin 23.1.6.