Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All Flow apps and features should work from non-root servlet context #4619

Closed
pleku opened this issue Sep 18, 2018 · 6 comments
Closed

All Flow apps and features should work from non-root servlet context #4619

pleku opened this issue Sep 18, 2018 · 6 comments

Comments

@pleku
Copy link
Contributor

pleku commented Sep 18, 2018

When running a Flow app, I want to use a non-root servlet mapping for it, because I have another another app mapped to the root context on the same domain

When the Flow app is mapped to non-root servlet context, All the things should work and we should also have ITs that verify those. Tests should verify (if don't already do so!) that the following things work:

  • basic stuff
    • routes and child routes
    • development time frontend resouces from webjars & local resources
      • make sure theme write is working for the components from webjars
    • production mode resources
  • push
  • spring (with the basic stuff)
    • spring with push
  • cdi (with the basic stuff)
    • cdi with push

Acceptance Criteria

We have verified by adding ITs for all the missing necessary things that those work also in non-root servlet context. Requires changes in vaadin/cdi and vaadin/spring projects too.

@pleku pleku added the testing label Sep 18, 2018
@mvysny
Copy link
Member

mvysny commented Sep 18, 2018

Attaching a sample project which reproduce the push issue. When run, the following appears in the browser:

WebSocket connection to 'ws://localhost:8080/vaadin/?v-r=push&v-uiId=0&v-pushId=605f0daa-0a48-4d63-a871-b2332bac23a5&X-Atmosphere-tracking-id=0&X-Atmosphere-Framework=2.3.2.vaadin1-javascript&X-Atmosphere-Transport=websocket&Content-Type=application/json;%20charset=UTF-8&X-atmo-protocol=true' failed: Error during WebSocket handshake: Unexpected response code: 200

And push falls back to long polling.

skeleton-starter-flow.zip

@pleku
Copy link
Contributor Author

pleku commented Sep 19, 2018

Also related #3600 (webjars handling broken when non-root servlet context)

@Klaudeta
Copy link
Contributor

Regarding the problem of websocket transport mode failing when using a custom mapping for Flow, until this issue will be fixed the work around for it is to have a separate vaadin servlet to map the /frontend:

For Java:

@WebServlet(name="frontendServlet", urlPatterns= { "/frontend/*"})
    public static class FrontendServlet extends VaadinServlet{	
    }

    @WebServlet(name="customServlet", urlPatterns= { "/vaadin/*"}, asyncSupported=true)
    public static class CustomVaadinServlet extends VaadinServlet{
    	
    	@Override
    	public void init() throws ServletException {
    		super.init();
    	}
    }

and for Spring boot:

@Bean
  @Order(Ordered.HIGHEST_PRECEDENCE-1)
  public ServletRegistrationBean<SpringServlet> vaadinServletBean() {
      SpringServlet springServlet = new SpringServlet(context);
	ServletRegistrationBean<SpringServlet> bean = new ServletRegistrationBean<>(
        springServlet, "/vaadin/*");
	bean.setAsyncSupported(true);
       bean.setName("springServlet");
       return bean;
  }
  
  @Bean
  @Order(Ordered.HIGHEST_PRECEDENCE)
  public ServletRegistrationBean<VaadinServlet> vaadinResourcesServletBean() {
      VaadinServlet vaadinServlet = new VaadinServlet();
	ServletRegistrationBean<VaadinServlet> bean = new ServletRegistrationBean<>(
			vaadinServlet, "/frontend/*");
      bean.setName("frontendServlet");
      return bean;
  }

In Spring Boot if /frontend is mapped using SpringServlet it still doesn't work, Atmosphere still picks up /frontend no matter ordering of mapping paths

@JulianFeinauer
Copy link
Contributor

Hi folks, what is the current state of this issue? I am also missing a bit of documentation about that in current flows doc. Is it easy / safe to use vaadin on non root Context?

@atistrcsn
Copy link

Hi. I am interested too. Is any resolution?

@mstahv
Copy link
Member

mstahv commented Feb 2, 2021

@JulianFeinauer & @atistrcsn, all known issues should be solved. This issue has just been left hanging, because some cases might not have ITs. I'll close this issue as it is causing confusion. If you find an issue, create a new bug report.

@mstahv mstahv closed this as completed Feb 2, 2021
OLD Vaadin Flow bugs & maintenance (Vaadin 10+) automation moved this from Internal Backlog / Technical Debt to Closed Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants