V23: Cannot add a custom VaadinServlet in plain servlet starter
See original GitHub issueDescription of the bug
Tried the V23 skeleton-starter-flow by adding a custom VaadinServlet class and it crashes the application in a way that requesting http://localhost:8080/ would result in listing root directory contents instead of loading the MainView
. It seems that having "/VAADIN/*"
is a must with the latest versions, but the other custom urlPattern such as "/vaadin/*"
or "/asdf/*"
is arbitrary. Basically, the presence of any custom VaadinServlet
is enough to break the application’s normal behavior. Adding a HttpServlet
is fine and works as expected.
Minimal reproducible example
- Download https://github.com/vaadin/skeleton-starter-flow/archive/v23.zip and unzip
- Add a custom VaadinServlet class:
import com.vaadin.flow.server.VaadinServlet;
import javax.servlet.annotation.WebServlet;
@WebServlet(asyncSupported = true, urlPatterns = { "/vaadin/*", "/VAADIN/*"})
public class WebComponentVaadinServlet extends VaadinServlet {
}
- Run:
mvn clean jetty:run
- Hit the http://localhost:8080/
Expected behavior
To see the MainView
loaded.
Actual behavior
It lists root directory contents:
Versions:
- Vaadin / Flow version: Platform v23.1.4 and v23.2.0.alpha3
- Java version: 17
- OS version: MacOs
- Browser version (if applicable): Firefox 102.0.1 (64-bit), Chrome 103.0.5060.134 (Official Build) (x86_64)
- Application Server (if applicable): Jetty
- IDE (if applicable): N/A
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
java - Vaadin 23 cannot import annotation ... - Stack Overflow
In the Vaadin 23 documentation, precisely here it show an example which includes the java annotation @VaadinServletConfiguration .
Read more >How to create Servlet? - Vaadin
Hi, I am trying to create a servlet, from that i can regist my ... false) public class CustomServlet extends VaadinServlet implements SessionInitListener, ......
Read more >Servlet - Apache Camel
The Servlet component provides HTTP based endpoints for consuming HTTP requests that arrive at a HTTP endpoint that is bound to a published...
Read more >Vaadin Resource Planner - ADocLib
Integrating An Existing GWT Widget In simple Vaadin Servlet deployment the ... an App Starter to give you a head start building your...
Read more >Upgrade Guide Generator | Upgrading | Vaadin Docs
Instructions for upgrading to the latest Vaadin version. To run applications or components developed with Vaadin 7 or 8 inside an application written...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My opinion is that if a user configures Vaadin to work on a mapping different from root, Vaadin should do nothing to prevent listing. With jetty (but this holds for other containers) it is the default servlet that handles listing So if the Vaadin servlet is not mapped to root, IMO it is up to the user to configure the servlet container to avoid listing.
If we define a custom servlet with a mapping different from root, I think it is expected not to see the main view at http://localhost:8080/. I expect to see it for example at http://localhost:8080/asdf/ if mapping is
/asdf/*, /VAADIN/*
And in this case it works for me