java websocket 1.0 tomcat_使用Spring MVC的websocket配置时 Tomcat启动报错

在使用Spring MVC配置WebSocket时遇到Tomcat启动报错,具体为Bean创建异常。错误源于Tomcat版本过低,官方推荐使用7.0.47+版本。升级到apache-tomcat-7.0.82后,问题得到解决。
摘要由CSDN通过智能技术生成

在使用Spring MVC的websocket配置时 Tomcat启动报错

错误信息如下:

[ERROR][localhost-startStop-1] org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:502) Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.server.support.WebSocketHandlerMapping#0': Cannot resolve reference to bean 'org.springframework.web.socket.server.support.WebSocketHttpRequestHandler#0'

while setting bean property 'urlMap' with key [/websocket]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.server.support.WebSocketHttpRequestHandler#0': Cannot resolve reference to bean

'org.springframework.web.socket.server.support.DefaultHandshakeHandler#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.socket.server.support.DefaultHandshakeHandler#0':

Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.socket.server.support.DefaultHandshakeHandler]: Constructor threw exception; nested exception is java.lang.IllegalStateException:

No suitable default RequestUpgradeStrategy found

原因是因为Tomcat版本太老,之前一直用的是apache-tomcat-7.0.42,Spring官网说要用Tomcat7.0.47+的版本(https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#websocket-server),果断升级Tomcat版本为apache-tomcat-7.0.82,问题解决。

附原文:

Currently the list includes WebSocket runtimes such as Tomcat 7.0.47+, Jetty 9.1+, GlassFish 4.1+, WebLogic 12.1.3+, and Undertow 1.0+ (and WildFly 8.0+).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值