question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

V23: Cannot add a custom VaadinServlet in plain servlet starter

See original GitHub issue

Description 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

  1. Download https://github.com/vaadin/skeleton-starter-flow/archive/v23.zip and unzip
  2. 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 {
}
  1. Run: mvn clean jetty:run
  2. Hit the http://localhost:8080/

Expected behavior

To see the MainView loaded.

Actual behavior

It lists root directory contents: Screenshot 2022-08-08 at 13 45 41

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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mcollovaticommented, Aug 8, 2022

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.

1reaction
mcollovaticommented, Aug 8, 2022

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found