Spring websocket example - error - Are you running in a Servlet container that supports J SR-356?

半腔热情 提交于 2020-01-03 03:58:12

问题


I am trying to run the Spring 4 example given @ https://spring.io/guides/gs/messaging-stomp-websocket. When I try to connect to socket, it throws me following exception. As per the example you need tomcat 7.0.50 and I checked the executable jar which has right version of tomcat. Any pointer would be helpful.

java.lang.IllegalArgumentException: No 'javax.websocket.server.ServerContainer'   ServletContext attribute. Are you running in a Servlet container that supports JSR-356?

回答1:


Check that you have tomcat7-websocket.jar and websocket-api.jar bundled in your executable jar - perhaps you're just getting vanilla tomcat without the extra websocket bits.




回答2:


I got the same error message in another use case: I deactivated auto configuration and added WebSocketConfig manually to the configuration. Then I got the abovementioned error message.

Fixing the problem was easy: just adding WebSocketAutoConfiguration to the configuration.



来源:https://stackoverflow.com/questions/21523693/spring-websocket-example-error-are-you-running-in-a-servlet-container-that-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!