Skip to content

ServerEndpointExporter causes refresh to fail with java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available [SPR-12340] #16945

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 7507560, 10328f1

Backported to: 4.0.8

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions