Closed
Description
Andy Wilkinson opened SPR-12340 and commented
This is the same problem as #16725 but the symptom's changed. Sorry for not testing the fix when it was made in 4.0.7.
The failure's now an IllegalStateException:
Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available
at org.springframework.util.Assert.state(Assert.java:385)
at org.springframework.web.socket.server.standard.ServerEndpointExporter.afterPropertiesSet(ServerEndpointExporter.java:116)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
... 15 more
The reason is still largely the same. In initApplicationContext, ServerEndpointExporter assumes that the ServletContext will be available on the WebApplicationContext. This isn't true in Spring Boot and leaves ServerEndpointExporter without a ServerContainer.
AFAICT, ServerEndpointExporter needs to defer its use of the ServletContext until ServletContextAware processing.
Affects: 4.0.7, 4.1.1
Issue Links:
- ServerEndpointExporter causes application context refresh to fail with an NPE when used in a Spring Boot app [SPR-12109] #16725 ServerEndpointExporter causes application context refresh to fail with an NPE when used in a Spring Boot app
Referenced from: commits 7507560, 10328f1
Backported to: 4.0.8