2

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?
Amit
  • 1,582
  • 2
  • 12
  • 20

3 Answers3

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.

Paul Adamson
  • 1,971
  • 2
  • 17
  • 22
  • thx Paul. I dont see both of these jars in executable. Its has tomcat-embed-core-7.0.50.jar, tomcat-embed-jasper-7.0.50.jar, spring-websocket-4.0.0.RELEASE.jar etc. – Amit Feb 05 '14 at 14:10
  • The class you're missing 'javax.websocket.server.ServerContainer' lives in websocket-api.jar which you can get from the standard tomcat download. – Paul Adamson Feb 06 '14 at 15:38
  • I am able to solve this using tomcat7:run which forced maven to download right version of tomcat. Thx Paul. – Amit Feb 08 '14 at 12:16
0

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.

rwitzel
  • 1,605
  • 15
  • 20
0

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.

Naruto Sempai
  • 4,447
  • 5
  • 32
  • 50