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

StackOverflow https://stackoverflow.com/questions/21523693

  •  06-10-2022
  •  | 
  •  

Вопрос

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?
Это было полезно?

Решение

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.

Другие советы

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.

I know that this is an ancient thread but I ran into this error and resolved it in modern times by adding implementation("org.springframework.boot:spring-boot-starter-tomcat") explicitly to my project.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top