-
spring websocket 问题5
16:12:36.662 [localhost-startStop-1] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping()] threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) [spring-web-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887) [catalina.jar:7.0.41]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) [catalina.jar:7.0.41]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.41]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) [catalina.jar:7.0.41]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) [catalina.jar:7.0.41]
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [na:1.7.0_21]
at java.util.concurrent.FutureTask.run(FutureTask.java:166) [na:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_21]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_21]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_21]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping()] threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
... 24 common frames omitted
Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.web.socket.server.support.DefaultHandshakeHandler.initRequestUpgradeStrategy(DefaultHandshakeHandler.java:107) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.server.support.DefaultHandshakeHandler.<init>(DefaultHandshakeHandler.java:89) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration.getOrCreateHandshakeHandler(AbstractWebSocketHandlerRegistration.java:131) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration.getMappings(AbstractWebSocketHandlerRegistration.java:119) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.ServletWebSocketHandlerRegistry.getHandlerMapping(ServletWebSocketHandlerRegistry.java:67) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping(WebSocketConfigurationSupport.java:36) ~[spring-websocket-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6.CGLIB$webSocketHandlerMapping$3(<generated>) ~[spring-core-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6$$FastClassBySpringCGLIB$$eaf8189e.invoke(<generated>) ~[spring-core-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312) ~[spring-context-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6.webSocketHandlerMapping(<generated>) ~[spring-core-4.0.6.RELEASE.jar:4.0.6.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_21]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_21]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_21]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_21]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166) ~[spring-beans-4.0.6.RELEASE.jar:4.0.6.RELEASE]
... 25 common frames omitted
一月 15, 2015 4:12:36 下午 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource [org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping()] threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:597)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1094)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:989)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
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)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.web.servlet.HandlerMapping org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping()] threw exception; nested exception is java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
... 24 more
Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found
at org.springframework.web.socket.server.support.DefaultHandshakeHandler.initRequestUpgradeStrategy(DefaultHandshakeHandler.java:107)
at org.springframework.web.socket.server.support.DefaultHandshakeHandler.<init>(DefaultHandshakeHandler.java:89)
at org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration.getOrCreateHandshakeHandler(AbstractWebSocketHandlerRegistration.java:131)
at org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration.getMappings(AbstractWebSocketHandlerRegistration.java:119)
at org.springframework.web.socket.config.annotation.ServletWebSocketHandlerRegistry.getHandlerMapping(ServletWebSocketHandlerRegistry.java:67)
at org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport.webSocketHandlerMapping(WebSocketConfigurationSupport.java:36)
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6.CGLIB$webSocketHandlerMapping$3(<generated>)
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6$$FastClassBySpringCGLIB$$eaf8189e.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at org.springframework.web.socket.config.annotation.DelegatingWebSocketConfiguration$$EnhancerBySpringCGLIB$$72432fa6.webSocketHandlerMapping(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
... 25 more
2015年1月15日 16:17
1个答案 按时间排序 按投票排序
-
spring4下的websocket默认使用jackson相关jar包,导入:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.3</version>
</dependency>
即可。2015年12月08日 18:30
相关推荐
Spring框架提供了对WebSocket的支持,使得在Java后端开发中集成WebSocket变得简单。在这个名为"spring websocket"的项目中,我们将会实现三个主要功能:客户端之间的消息传递、客户端向服务器发送消息以及服务器向...
**Spring WebSocket 完整Demo详解** WebSocket是一种在客户端与服务器之间建立长连接的协议,它提供了双向通信的能力,使得服务器可以主动向客户端推送数据。在Web应用中,Spring框架提供了对WebSocket的支持,使得...
在这个"spring+websocketdemo"中,我们将探讨如何结合Spring框架和WebSocket技术来构建一个实时通信的应用,并引入Netty作为WebSocket的服务器端实现。 首先,Spring框架是Java企业级应用开发的主流选择,它提供了...
在这个"spring websocket 测试项目"中,开发者可能已经遇到了一些常见问题,例如连接建立失败、消息传输错误或者客户端和服务器之间的同步问题等。这些问题可能源于配置错误、网络问题、协议不兼容或者代码逻辑错误...
考虑到安全问题,WebSocket连接通常需要进行身份验证。Spring Security可以集成到WebSocket应用中,以确保只有经过授权的用户才能建立连接并参与聊天。 9. **性能优化** 对于大型聊天应用,可能需要考虑负载均衡...
Spring框架,作为Java开发中的主流框架,提供了对WebSocket的支持,使得开发者可以轻松地在Spring应用中集成WebSocket功能。 在这个"websocket+spring"项目中,前端和后端的代码都包含了实现WebSocket通信的逻辑。...
《Spring WebSocket 中文注释案例详解》 在现代Web开发中,实时通信功能变得越来越重要,Spring框架提供了WebSocket支持,使得服务器与客户端可以进行双向通信,实现高效、低延迟的数据交换。本文将深入探讨一个...
在Spring框架中,Spring Boot提供了对WebSocket的支持,使得开发者可以方便地集成WebSocket功能到自己的应用程序中。 在"spring websocket的demo"中,我们看到的是一个基于Spring Boot实现的WebSocket服务器和...
在现代Web开发中,实时通信已经成为一个不可或缺的功能,Spring、Netty和WebSocket的结合为构建高性能、低延迟的实时应用提供了强大的解决方案。本实例将详细探讨如何利用这三种技术进行集成,实现高效的双向通信。 ...
在本文中,我们将深入探讨如何使用Spring框架,特别是Spring WebSocket,来创建一个简单的WebSocket应用程序。这对于初学者来说是一个很好的起点,因为它提供了一个直观的理解和实践机会。 首先,让我们了解Spring ...
Spring WebSocket是Spring框架提供的一套完整的WebSocket支持,它使得在Spring应用中集成WebSocket变得简单。 **一、WebSocket简介** WebSocket API设计目标是为了提供低延迟、高效率的双向通信机制。与HTTP不同,...
2. **SockJS**: 为了解决WebSocket在不同浏览器的兼容性问题,Spring提供了SockJS协议,它是一种透明的WebSocket替代方案,能在所有现代浏览器中工作。 3. **STOMP**: 作为WebSocket的消息传输协议,STOMP(Simple ...
SpringWebSocket-master.zip是一个包含Spring Boot应用的示例项目,展示了如何使用WebSocket技术和STOMP协议实现前后端通信。WebSocket是一种在单个TCP连接上进行全双工通信的协议,相较于传统的HTTP请求,它允许...
SpringWebSocket.jar
《Spring WebSocket深度解析》 WebSocket协议的出现,为实时、双向通信提供了强大的支持,而Spring框架的WebSocket模块(Spring WebSocket)则将这一技术完美地融入到企业级开发中。Spring WebSocket使得开发者能够...
6. **错误处理与断线重连**:为确保稳定性,需要处理WebSocket连接中断的情况,如网络问题或服务器重启。可以设置心跳机制检查连接状态,并在断线后尝试重新连接。 在实际应用中,Spring的WebSocket支持和ECharts的...
这个"Spring-websocket-master.zip"压缩包提供了一个基于Spring框架的WebSocket实时通信的示例项目,可以帮助开发者理解并实现WebSocket在实际中的应用。 首先,Spring WebSocket是Spring Framework的一部分,它...
在Spring框架中,Spring WebSocket提供了全面的支持,使得开发人员可以轻松地集成WebSocket功能到他们的应用程序中。下面将详细介绍Spring WebSocket通信应用实例,包括其工作原理、配置、心跳监测以及如何构建一个...
**Spring WebSocket 深度解析** WebSocket 是一种在客户端与服务器之间建立长连接的协议,它允许双方进行双向通信,而不仅仅是服务器向客户端推送数据。在Web应用中,WebSocket为实时交互提供了强大的支持,比如...