spring-websocket框架搭建遇到的问题解决方案汇总

原创 2014年08月06日 10:50:21

问题1 org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server

严重: Servlet.service() for servlet [SpringMVC] in context with path [/ZHDM] threw exception [Request processing failed; nested exception is org.springframework.web.socket.server.HandshakeFailureException: Uncaught failure for request http://125.221.225.118:8080/ZHDM/websocket; nested exception is java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer] with root cause
java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer
	at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getContainer(AbstractStandardUpgradeStrategy.java:76)
	at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:85)
	at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:47)
	at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getSupportedExtensions(AbstractStandardUpgradeStrategy.java:68)
	at org.springframework.web.socket.server.support.DefaultHandshakeHandler.doHandshake(DefaultHandshakeHandler.java:206)
	at org.springframework.web.socket.server.support.WebSocketHttpRequestHandler.handleRequest(WebSocketHttpRequestHandler.java:120)
	at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:301)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:136)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:74)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1015)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:652)
	at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:277)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2451)
	at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2440)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:744)
解决方案:

出现这个问题的原因是,apache的websocket包和javax-servlet包冲突了,找到Apache Tomcat的webApp目录,打开你部署的项目文件夹,依次打开WEB-INF/lib,找到javaee-api-7.0.jar,删除,再重新启动项目。

版权声明:本文为博主原创文章,未经博主允许不得转载。

Tomcat中通过JavaEE实现的WebSocket程序获取ServletContext

Tomcat中通过JavaEE实现的WebSocket程序获取ServletContext

Spring Websocket 使用笔记

spring websocket框架使用笔记

关于我使用spring mvc框架做文件上传时遇到的问题

昨天尝试着用spring mvc框架做文件上传,犯了挺多不该犯的毛病问题1:org.springframework.web.util.NestedServletException: Request p...
  • lingirl
  • lingirl
  • 2007年07月29日 10:30
  • 23709

HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerException

HTTP Status 500 - Request processing failed; nested exception is java.lang.NullPointerExceptiontype ...

利用spring-websocket包搭建websocket服务

折腾了将近一天,终于搭建好websocket服务,中间遇到不少的坑,现在记录一下,也供他们参考少走弯路。 开发环境:4.2.5.RELEASE     Tomcat8   jdk8  maven ...
  • linlzk
  • linlzk
  • 2016年04月07日 16:02
  • 36760

Tomcat中的WebSocket

什么是WebSocket我们知道,Comet是在HTTP单向通信基础上模拟服务器与客户端浏览器的双向通讯,不同的Comet方案存在不同的缺陷,无论是跨浏览器层面还是规范限制。而且因为是一种模拟实现,所...

给golang增加websocket模块

最近打算做一款类似腾讯>的h5游戏,之前打算用skynet来做,所以给skynet增加了websocket模块,https://github.com/Skycrab/skynet_websocket。...

Spring websocket 使用

项目中用到了消息的实时推送,查资料后用到了Spring websocket,找了很多资料,还是感觉官方的帮助文档写得最为清晰,现摘录如下。 另外还有两个非常经典的例子:一个是https://spri...

看完让你彻底搞懂Websocket原理

偶然在知乎上看到一篇回帖,瞬间觉得之前看的那么多资料都不及这一篇回帖让我对 websocket 的认识深刻有木有。所以转到我博客里,分享一下。比较喜欢看这种博客,读起来很轻松,不枯燥,没有布道师的阵仗...

WebSocket协议深入理解

1.WebSocket和HTTP的关系WebSocket只有在建立握手连接的时候借用了HTTP协议的头,连接成功后的通信部分都是基于TCP的连接。总体来说,WebSocket协议是HTTP协议的升级版...
  • fareise
  • fareise
  • 2016年08月11日 20:30
  • 4636
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:spring-websocket框架搭建遇到的问题解决方案汇总
举报原因:
原因补充:

(最多只允许输入30个字)