spring – java.lang.IllegalStateException:SockJsMessageCodec是必需的但不可用:

前端之家收集整理的这篇文章主要介绍了spring – java.lang.IllegalStateException:SockJsMessageCodec是必需的但不可用:前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

你好我是websocket的新手.我不知道为什么我得到这个例外.

 java.lang.IllegalStateException: A SockJsMessageCodec is required but not available: Add Jackson 2 to the classpath,or configure a custom SockJsMessageCodec.
    at org.springframework.util.Assert.state(Assert.java:385)
    at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.getMessageCodec(TransportHandlingSockJsService.java:130)
    at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.handleMessage(WebSocketServerSockJsSession.java:187)
    at org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler.handleTextMessage(SockJsWebSocketHandler.java:92)
    at org.springframework.web.socket.handler.AbstractWebSocketHandler.handleMessage(AbstractWebSocketHandler.java:43)
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.handleTextMessage(StandardWebSocketHandlerAdapter.java:112)
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter.access$000(StandardWebSocketHandlerAdapter.java:42)
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:82)
    at org.springframework.web.socket.adapter.standard.StandardWebSocketHandlerAdapter$3.onMessage(StandardWebSocketHandlerAdapter.java:79)
    at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:369)
    at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:468)
    at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:272)
    at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:116)
    at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:54)
    at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:192)
    at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:178)
    at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:92)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:601)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    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:745) 

我的控制台输出

opening Web Socket... stomp.js:145
Web Socket Opened... stomp.js:145
>>> CONNECT
accept-version:1.1,1.0
heart-beat:10000,10000   stomp.js:145


Whoops! Lost connection to undefined 

这是我的bjplayer-servlet.xml

对于我的控制器

@MessageMapping("/joinRoom")
@SendTo("/topic/lobby")
public List

我的JavaScript

猜你在找的Spring相关文章