• -------------------------------------------------------------
  • ====================================

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

编程语言 dewbay 8年前 (2017-05-15) 3913次浏览 已收录 0个评论 扫描二维码

问题 1 org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server[javascript] view plain copy 严重: 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,删除,再重新启动项目。

来源: spring-websocket 框架搭建遇到的问题解决方案汇总 – 博客频道 – CSDN.NET


露水湾 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:spring-websocket框架搭建遇到的问题解决方案汇总
喜欢 (3)
[]
分享 (0)
关于作者:
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址