Vaadin Upload

Hi,

I’m trying to migrate from Vaadin 8 to Flow, unfortunately it is very difficult. Now I have problem with the Upload component.

I need to map Vaadin Servlet to /vaadin servlet path as /* is mapped by Struts 2 framework which is the base of the application. Vaadin is used in embedded mode using exporters.

When I try to use the Upload component I got “forbidden” error because the POST request “/VAADIN/dynamic/resource/15/9b4bd855-e7cc-432f-b787-fa1171de341f/upload” results 404. This URL is generated in the target attribute of vaadin-upload component. This request won’t be handled by Vaadin servlet as I mapped it to /vaadin servlet path.

After that I tried to add an other /VAADIN/* servlet mappding to Vaadin Servlet to be able to process this request. The StreamRequestHandler should handle this request but it denies it as pathInfo doesn’t start with “VAADIN/dynamic/resource/” as pathInfo real value is “dynamic/resource”, because pathInfo is the URL part after the servlet path (/VAADIN). So it seems it won’t work if I set /VAADIN/* mapping for Vaadin servlet.

After that I tried to map VaadinServlet to /* but in this case there are errors about Atmosphere which I cannot handle as there is no useful error message:

17:06:28,137 ERROR [org.atmosphere.util.IOUtils]
 (ServerService Thread Pool -- 313/) : java.util.NoSuchElementException
	at java.util.ArrayList$Itr.next(ArrayList.java:862) [rt.jar:1.8.0_212]

	at java.util.Collections$UnmodifiableCollection$1.next(Collections.java:1042) [rt.jar:1.8.0_212]

	at org.atmosphere.util.IOUtils.guestRawServletPath(IOUtils.java:290) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.util.IOUtils.guestServletPath(IOUtils.java:255) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:65) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:42) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_212]

	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_212]

	at sun.reflect.DelegatingConstructorAccessorImpl.__newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_212]

	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45009) [rt.jar:1.8.0_212]

	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45012) [rt.jar:1.8.0_212]

	at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [rt.jar:1.8.0_212]

	at org.atmosphere.cpr.DefaultAsyncSupportResolver.newCometSupport(DefaultAsyncSupportResolver.java:237) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolveWebSocket(DefaultAsyncSupportResolver.java:308) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.cpr.DefaultAsyncSupportResolver.resolve(DefaultAsyncSupportResolver.java:294) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.cpr.AtmosphereFramework.autoDetectContainer(AtmosphereFramework.java:2092) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:914) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.cpr.AtmosphereFramework.init(AtmosphereFramework.java:838) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at com.vaadin.flow.server.communication.PushRequestHandler.initAtmosphere(PushRequestHandler.java:218) [flow-server-2.0.7.jar:2.0.7]

	at com.vaadin.flow.server.communication.JSR356WebsocketInitializer.initAtmosphereForVaadinServlet(JSR356WebsocketInitializer.java:184) [flow-server-2.0.7.jar:2.0.7]

	at com.vaadin.flow.server.communication.JSR356WebsocketInitializer.init(JSR356WebsocketInitializer.java:149) [flow-server-2.0.7.jar:2.0.7]

	at com.vaadin.flow.server.communication.JSR356WebsocketInitializer.contextInitialized(JSR356WebsocketInitializer.java:118) [flow-server-2.0.7.jar:2.0.7]

	at com.vaadin.flow.server.startup.ServletContextListeners.contextInitialized(ServletContextListeners.java:40) [flow-server-2.0.7.jar:2.0.7]



Caused by: java.lang.IllegalStateException: Unable to configure jsr356 at that stage
	at org.atmosphere.util.IOUtils.guestRawServletPath(IOUtils.java:297) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.util.IOUtils.guestServletPath(IOUtils.java:255) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:65) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]

	at org.atmosphere.container.JSR356AsyncSupport.<init>(JSR356AsyncSupport.java:42) [atmosphere-runtime-2.4.30.slf4jvaadin1.jar:2.4.30.slf4jvaadin1]


Is it possible to put Vaadin servlet after a servlet path and make everything work? Or it must be mapped to /* and is there any solution to avoid the above error?

Maybe it is a bug in StreamRequestHandler and getPathInfo() should be changed to getServletPath() + getPathInfo() for the /VAADIN + /vaadin servlet mapping work, isn’t it?

Thanks, Tamás