Avoid Atmosphere using a null URL to create a URLClassLoader

Unlike Java 8, 9, and 10, Java 11 does not tolerate a null URL being
used to create a URLClassLoader. The Atmosphere sample looks for
a resource named /WEB-INF/classes which only exists in a packaged
war application. In all other cases the resulting URL is null.
Atmosphere uses this to create a URLClassLoader which fails on Java
11.

This commit updates the sample to customize the handlers path. There
are other web application-specific assumptions in Atmosphere, such as
the scanning of WEB-INF/lib by default. This change appears to get
the sample going, but we should, perhaps, consider removing it in the
longer term, particularly as Boot itself has no Atmosphere
integration.

See gh-14028
This commit is contained in:
Andy Wilkinson
2018-08-14 13:29:46 +01:00
parent 1dd8c83d77
commit e0d67ae703

View File

@@ -48,8 +48,10 @@ public class SampleAtmosphereApplication {
public ServletRegistrationBean<AtmosphereServlet> atmosphereServlet() {
// Dispatcher servlet is mapped to '/home' to allow the AtmosphereServlet
// to be mapped to '/chat'
AtmosphereServlet atmosphereServlet = new AtmosphereServlet();
atmosphereServlet.framework().setHandlersPath("/");
ServletRegistrationBean<AtmosphereServlet> registration = new ServletRegistrationBean<>(
new AtmosphereServlet(), "/chat/*");
atmosphereServlet, "/chat/*");
registration.addInitParameter("org.atmosphere.cpr.packages", "sample");
registration.addInitParameter("org.atmosphere.interceptor.HeartbeatInterceptor"
+ ".clientHeartbeatFrequencyInSeconds", "10");