ServerEndpointExporter causes application context refresh to fail with an NPE when used in a Spring Boot app [SPR-12109] #16725
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Andy Wilkinson opened SPR-12109 and commented
This Boot app illustrates the problem:
Running it fails with a
NullPointerException
:ServerEndpointExporter
assumes thatWebApplicationContext.getServletContext()
will return a non-null value when it's called from withinsetApplicationContext(context)
. This assumption doesn't hold true in a Boot application as the embedded Tomcat server hasn't been started yet.A work around is to replace the
ServerEndpointExporter
bean with the following:This defers
ServerEndpointExporter
's processing until a time when theServletContext
is availableAffects: 4.0.6
Reference URL: http://stackoverflow.com/questions/25390100/using-java-api-for-websocket-jsr-356-with-spring-boot/25425384#25425384
Issue Links:
Referenced from: commits 379e5ab, 11805b6
Backported to: 4.0.7
The text was updated successfully, but these errors were encountered: