-1

I wanted to replace Tomcat in Vaadin. Wanted to replace it with Under / Jetty / Netty. Currently I am using spring boot and replaced tomcat with undertow. Unfortunatelty this setup disables WEB_PUSH in Vaadin. Is there any way around this ? or maybe a way to replace tomcat inside vaadin ? or to make vaadin webpush to work with undertow / netty / jetty ? I really need something more lightweight. Tomcat is very heavy.

If I replace tomcat with undertow, this error occurs:

java.lang.IllegalStateException: Unable to configure jsr356 at that stage. ServerContainer is null
    at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:58) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:47) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[na:na]
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483) ~[na:na]
    at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:126) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:197) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:183) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2078) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:908) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:832) ~[atmosphere-runtime-3.0.3.slf4jvaadin1.jar:3.0.3.slf4jvaadin1]
    at com.vaadin.flow.server.communication.PushRequestHandler.initAtmosphere(PushRequestHandler.java:263) ~[flow-server-24.1.5.jar:24.1.5]
    at com.vaadin.flow.server.communication.PushRequestHandler.<init>(PushRequestHandler.java:98) ~[flow-server-24.1.5.jar:24.1.5]
    at com.vaadin.flow.server.VaadinServletService.createRequestHandlers(VaadinServletService.java:105) ~[flow-server-24.1.5.jar:24.1.5]
    at com.vaadin.flow.server.VaadinService.init(VaadinService.java:229) ~[flow-server-24.1.5.jar:24.1.5]
    at com.vaadin.flow.spring.SpringVaadinServletService.init(SpringVaadinServletService.java:101) ~[vaadin-spring-24.1.5.jar:na]
    at com.vaadin.flow.spring.SpringServlet.createServletService(SpringServlet.java:115) ~[vaadin-spring-24.1.5.jar:na]
    at com.vaadin.flow.server.VaadinServlet.createServletService(VaadinServlet.java:336) ~[flow-server-24.1.5.jar:24.1.5]
    at com.vaadin.flow.server.VaadinServlet.init(VaadinServlet.java:132) ~[flow-server-24.1.5.jar:24.1.5]
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:944) ~[tomcat-embed-core-10.1.11.jar:10.1.11]
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:808) ~[tomcat-embed-core-10.1.11.jar:10.1.11]
    at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedContext.load(TomcatEmbeddedContext.java:84) ~[spring-boot-3.1.2.jar:3.1.2]

This indicates that

@Push(PushMode.AUTOMATIC,transport = Transport.WEBPUSH)

wont work. I want this to work with undertow

1 Answers1

0

Tomcat is not inside Vaadin, but in Spring Boot. You can use the instructions in Spring Boot reference manual to replace Tomcat with e.g. Undertow. Not that spring-boot-starter-web dependency is not necessarily directly in your pom.xml, but it is transitively brought in by Vaadin dependencies. I tried adding following snippet to basic Vaadin 24.1 project and after that Undertow is used instead of Tomcat and server push works just fine for me:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <!-- Exclude the Tomcat dependency -->
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-undertow</artifactId>
    </dependency>
mstahv
  • 1,784
  • 9
  • 7
  • This is what I did but when I exclude tomcat the vaadin web push stops working. @Push(PushMode.AUTOMATIC,transport = Transport.LONG_POLLING) only works @Push(PushMode.AUTOMATIC,transport = Transport.WEBSOCKET) does not work WEBSOCKET is more lightweight than LONG_POOLING – Jason The Dynamite Aug 02 '23 at 10:10
  • Works for me. Also with pure websocket mode. You should add versions you are using (of pretty much everything) and possible errors in the log. Preferably also an example code you use that don't work. Otherwise it is quite impossible to help. – mstahv Aug 02 '23 at 16:52