问题
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