ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.web...

 1 21:09:22.221 [MessageBroker-3] INFO  c.t.s.s.impl.StockNewsServiceImpl - [2017-12-16 21:09:22] execute fetch stock news, result = 0
 2 21:09:32.158 [MessageBroker-2] INFO  c.t.s.s.impl.StockNewsServiceImpl - [2017-12-16 21:09:32] execute fetch stock news, result = 0
 3 21:09:42.180 [MessageBroker-2] INFO  c.t.s.s.impl.StockNewsServiceImpl - [2017-12-16 21:09:42] execute fetch stock news, result = 0
 4 org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/thinkvenus-websocket/482/g1y5fw42/websocket; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer
 5     at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:135)
 6     at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
 7     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
 8     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
 9     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
10     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
11     at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
12     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
13     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
14     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
15     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
16     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
17     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
18     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
19     at org.springframework.web.servlet.resource.ResourceUrlEncodingFilter.doFilter(ResourceUrlEncodingFilter.java:59)
20     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
21     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
22     at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
23     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
24     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
25     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
26     at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
27     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
28     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
29     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
30     at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
31     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
32     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
33     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
34     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
35     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
36     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
37     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
38     at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
39     at org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
40     at org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)
41 **********************异常开始**********************
42     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
43     at org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:108)
44 **********************异常结束**********************
45 
46     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
47     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
48     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
49     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
50     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
51     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
52     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
53     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
54     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
55     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
56     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
57     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
58     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2549)
59     at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2538)
60     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
61     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
62     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
63     at java.lang.Thread.run(Thread.java:748)
64 Caused by: org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer
65     at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:127)
66     at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:312)
67     at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:433)
68     at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:132)
69     ... 55 more
70 Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer
71     at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getContainer(AbstractStandardUpgradeStrategy.java:67)
72     at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:84)
73     at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:47)
74     at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getSupportedExtensions(AbstractStandardUpgradeStrategy.java:88)
75     at org.springframework.web.socket.server.support.AbstractHandshakeHandler.doHandshake(AbstractHandshakeHandler.java:272)
76     at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:123)
77     ... 58 more
78 21:09:52.177 [MessageBroker-4] INFO  c.t.s.s.impl.StockNewsServiceImpl - [2017-12-16 21:09:52] execute fetch stock news, result = 0

 

在stackflow上看到的解决方案:

https://samebug.io/exceptions/173734/java.lang.ClassCastException/orgapachetomcatwebsocketserverwsservercontainer

https://stackoverflow.com/questions/28348686/tomcat-8-and-websocket

Maven:

<dependency>
    <groupId>javax.websocket</groupId>
    <artifactId>javax.websocket-api</artifactId>
    <version>1.0</version>
    <scope>provided</scope>
</dependency>

Gradle:
providedCompile("javax.websocket:javax.websocket-api:1.1")

转载于:https://www.cnblogs.com/ThinkVenus/p/8047733.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值