From e0d67ae7033ee595f7f4985830c18759afc13d5e Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 14 Aug 2018 13:29:46 +0100 Subject: [PATCH] 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 --- .../java/sample/atmosphere/SampleAtmosphereApplication.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java index 4f6800bef0..9af08d0c55 100644 --- a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java +++ b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/SampleAtmosphereApplication.java @@ -48,8 +48,10 @@ public class SampleAtmosphereApplication { public ServletRegistrationBean atmosphereServlet() { // Dispatcher servlet is mapped to '/home' to allow the AtmosphereServlet // to be mapped to '/chat' + AtmosphereServlet atmosphereServlet = new AtmosphereServlet(); + atmosphereServlet.framework().setHandlersPath("/"); ServletRegistrationBean registration = new ServletRegistrationBean<>( - new AtmosphereServlet(), "/chat/*"); + atmosphereServlet, "/chat/*"); registration.addInitParameter("org.atmosphere.cpr.packages", "sample"); registration.addInitParameter("org.atmosphere.interceptor.HeartbeatInterceptor" + ".clientHeartbeatFrequencyInSeconds", "10");