Spring SockJS无法找到已注册的处理程序



我已经将SockJS服务的处理程序注册为

@Bean
public SimpleUrlHandlerMapping handlerMapping() {
SockJsService sockJsService = new DefaultSockJsService(sockJsTaskScheduler());
Map<String, Object> urlMap = new HashMap<String, Object>();
urlMap.put("/sockjs/cobrowse/agent/**", new SockJsHttpRequestHandler(sockJsService,   coBrowseSockJsAgentHandler()));
urlMap.put("/sockjs/cobrowse/customer/**", new SockJsHttpRequestHandler(sockJsService, coBrowseSockJsCustomerHandler()));
urlMap.put("/sockjs/cobrowse/admin/**", new SockJsHttpRequestHandler(sockJsService, coBrowseSockJsAdminHandler()));
SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
hm.setOrder(-1);
hm.setUrlMap(urlMap);
return hm;
}

但当我尝试使用其中一个注册的URL从客户端调用时,它会抛出一个异常!

org.springframework.web.socket.support.ExceptionWebSocketHandlerDecorator - ERROR -  Closing due to exception for SockJS session id=8cf_1l_6
java.lang.IllegalArgumentException: WebSocketHandler not found for SockJS session id=8cf_1l_6
at org.springframework.util.Assert.isTrue(Assert.java:65)
at org.springframework.web.socket.support.PerConnectionWebSocketHandler.getHandler(PerConnectionWebSocketHandler.java:91)
at org.springframework.web.socket.support.PerConnectionWebSocketHandler.handleTransportError(PerConnectionWebSocketHandler.java:97)
at org.springframework.web.socket.support.ExceptionWebSocketHandlerDecorator.handleTransportError(ExceptionWebSocketHandlerDecorator.java:79)
at org.springframework.web.socket.support.WebSocketHandlerDecorator.handleTransportError(WebSocketHandlerDecorator.java:64)
at org.springframework.web.socket.support.LoggingWebSocketHandlerDecorator.handleTransportError(LoggingWebSocketHandlerDecorator.java:66)
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.delegateError(AbstractSockJsSession.java:188)
at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.tryCloseWithSockJsTransportError(AbstractSockJsSession.java:255)
at org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession.initializeDelegateSession(WebSocketServerSockJsSession.java:122)
at org.springframework.web.socket.sockjs.transport.handler.SockJsWebSocketHandler.afterConnectionEstablished(SockJsWebSocketHandler.java:72)
at org.springframework.web.socket.adapter.StandardWebSocketHandlerAdapter.onOpen(StandardWebSocketHandlerAdapter.java:93)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:130)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:653)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1584)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1543)
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:722)

这更令人惊讶,因为直到昨天还在运行相同的代码——我这边并没有重大的更改。我的猜测是,这与spring jar有关,可能是夜间更新——我使用的是"4.0.0.BUILD-SNAPSHOT",但我没有以前的libs!

在这里发布它,如果有人遇到了这个,同时我正在尝试旧的libs——我不知道如何从官方回购中获得它(同一版本的旧版本!)。

我花了几个小时将代码与存储库进行比较,并试图找出问题所在——当我确信自己没有破坏任何东西时,我猜测可能是由于最新的JAR。我使用maven,所以我的回购今天早上更新了。由于libs来自Spring,所以这个猜测必须持续到最后!

我的猜测是正确的——当我将当前版本"4.0.0.BUILD-20130823.020236"替换为早期版本"4.0.0.BILD-20130814.154539-172"时——问题得到了解决。非常感谢微软回收站!

相关内容

  • 没有找到相关文章

最新更新