你好我是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
我的Jsp.
Room Name:
我的Jar文件.
spring-beans-4.1.0.RELEASE.jar
spring-context-4.1.0.RELEASE.jar
spring-context-support-4.1.0.RELEASE.jar
spring-core-4.1.0.RELEASE.jar
spring-expression-4.1.0.RELEASE.jar
spring-jdbc-4.1.0.RELEASE.jar
spring-jms-4.1.0.RELEASE.jar
spring-messaging-4.1.0.RELEASE.jar
spring-orm-4.1.0.RELEASE.jar
spring-tx-4.1.0.RELEASE.jar
spring-web-4.1.0.RELEASE.jar
spring-webmvc-4.1.0.RELEASE.jar
spring-websocket-4.1.0.RELEASE.jar
jackson-databind-2.3.4.jar
我错过了什么吗?例外情况说SockJsMessageCodec不可用..
请有人提前帮助我thnx ..
顺便说一句,这是我所遵循的演示. https://gerrydevstory.com/2014/03/04/stock-ticker-demo-webapp-using-spring-4-websocket/
最佳答案