首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为Spring Boot驱动的Vaadin应用程序启用服务器推送功能不起作用

为Spring Boot驱动的Vaadin应用程序启用服务器推送功能不起作用
EN

Stack Overflow用户
提问于 2014-06-17 20:56:27
回答 2查看 3.4K关注 0票数 1

在我们当前的项目中,我们希望在Spring Boot powered Vaadin应用程序中使用server-push。

我们遵循了维基文章https://vaadin.com/book/vaadin7/-/page/advanced.push.html中的说明(向pom.xml添加了vaadin-push依赖,向out UI类添加了@Push注释,没有在web.xml文件中设置async-supported,因为在这种情况下它不存在),并得到了以下错误消息:

代码语言:javascript
复制
2014-06-17 14:32:43,340 [http-nio-8080-exec-3] WARN  org.atmosphere.cpr.AtmosphereFramework - SessionSupport error. Make sure you define org.atmosphere.cpr.SessionSupport as a listener in web.xml instead
2014-06-17 14:32:44,981 [http-nio-8080-exec-3] WARN  org.atmosphere.cpr.DefaultAsyncSupportResolver - Found multiple containers, please specify which one to use: org.atmosphere.container.Tomcat7CometSupport, org.atmosphere.container.TomcatCometSupport,  until you do, Atmosphere will use:class org.atmosphere.container.Tomcat7CometSupport
2014-06-17 14:32:45,001 [http-nio-8080-exec-3] WARN  org.atmosphere.cpr.AtmosphereFramework - Failed using comet support: org.atmosphere.container.Tomcat7CometSupport, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar Is the NIO or APR Connector enabled?
2014-06-17 14:32:45,005 [http-nio-8080-exec-3] ERROR org.atmosphere.cpr.AtmosphereFramework - If you have more than one Connector enabled, make sure they both use the same protocol, e.g NIO/APR or HTTP for all. If not, org.atmosphere.container.BlockingIOCometSupport will be used and cannot be changed.
java.lang.IllegalStateException: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar
    at org.atmosphere.container.Tomcat7CometSupport.<clinit>(Tomcat7CometSupport.java:56) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
    (...)
2014-06-17 14:32:45,006 [http-nio-8080-exec-3] WARN  org.atmosphere.cpr.AtmosphereFramework - Using org.atmosphere.container.BlockingIOCometSupport

2014-06-17 14:32:58,684 [http-nio-8080-exec-1] ERROR com.vaadin.server.DefaultErrorHandler - 
java.lang.IllegalStateException: Cannot suspend a response longer than the session timeout. Increase the value of session-timeout in web.xml
    at org.atmosphere.cpr.AtmosphereResourceImpl.suspend(AtmosphereResourceImpl.java:314) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
    (...)

在读取堆栈溢出线程Getting rid of web.xml in Vaadin 7 with VaadinServlet之后,我们向UI类添加了一个静态servlet

代码语言:javascript
复制
@WebServlet(asyncSupported = true)
public static class Servlet extends VaadinServlet {
}

并得到相同的错误消息:

代码语言:javascript
复制
2014-06-17 14:33:52,928 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - SessionSupport error. Make sure you define org.atmosphere.cpr.SessionSupport as a listener in web.xml instead
2014-06-17 14:33:54,557 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.DefaultAsyncSupportResolver - Found multiple containers, please specify which one to use: org.atmosphere.container.Tomcat7CometSupport, org.atmosphere.container.TomcatCometSupport,  until you do, Atmosphere will use:class org.atmosphere.container.Tomcat7CometSupport
2014-06-17 14:33:54,577 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - Failed using comet support: org.atmosphere.container.Tomcat7CometSupport, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar Is the NIO or APR Connector enabled?
2014-06-17 14:33:54,581 [http-nio-8080-exec-1] ERROR org.atmosphere.cpr.AtmosphereFramework - If you have more than one Connector enabled, make sure they both use the same protocol, e.g NIO/APR or HTTP for all. If not, org.atmosphere.container.BlockingIOCometSupport will be used and cannot be changed.
java.lang.IllegalStateException: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar
    at org.atmosphere.container.Tomcat7CometSupport.<clinit>(Tomcat7CometSupport.java:56) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
   (...)
2014-06-17 14:33:54,582 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - Using org.atmosphere.container.BlockingIOCometSupport

2014-06-17 14:34:07,338 [http-nio-8080-exec-3] ERROR com.vaadin.server.DefaultErrorHandler - 
java.lang.IllegalStateException: Cannot suspend a response longer than the session timeout. Increase the value of session-timeout in web.xml
    at org.atmosphere.cpr.AtmosphereResourceImpl.suspend(AtmosphereResourceImpl.java:314) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
    (...)

为会话超时添加一个参数也不会改变任何事情:

代码语言:javascript
复制
@WebServlet(asyncSupported = true, initParams = { @WebInitParam(name = "session-timeout", value = "120") })
public static class Servlet extends VaadinServlet {
}

2014-06-17 14:36:18,636 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - SessionSupport error. Make sure you define org.atmosphere.cpr.SessionSupport as a listener in web.xml instead
2014-06-17 14:36:20,284 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.DefaultAsyncSupportResolver - Found multiple containers, please specify which one to use: org.atmosphere.container.Tomcat7CometSupport, org.atmosphere.container.TomcatCometSupport,  until you do, Atmosphere will use:class org.atmosphere.container.Tomcat7CometSupport
2014-06-17 14:36:20,303 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - Failed using comet support: org.atmosphere.container.Tomcat7CometSupport, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar Is the NIO or APR Connector enabled?
2014-06-17 14:36:20,307 [http-nio-8080-exec-1] ERROR org.atmosphere.cpr.AtmosphereFramework - If you have more than one Connector enabled, make sure they both use the same protocol, e.g NIO/APR or HTTP for all. If not, org.atmosphere.container.BlockingIOCometSupport will be used and cannot be changed.
java.lang.IllegalStateException: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.You must use the atmosphere-native-runtime dependency in order to use native Comet Support
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat7.jar
    at org.atmosphere.container.Tomcat7CometSupport.<clinit>(Tomcat7CometSupport.java:56) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
    (...)
2014-06-17 14:36:20,308 [http-nio-8080-exec-1] WARN  org.atmosphere.cpr.AtmosphereFramework - Using org.atmosphere.container.BlockingIOCometSupport

2014-06-17 14:36:44,341 [http-nio-8080-exec-9] ERROR com.vaadin.server.DefaultErrorHandler - 
java.lang.IllegalStateException: Cannot suspend a response longer than the session timeout. Increase the value of session-timeout in web.xml
    at org.atmosphere.cpr.AtmosphereResourceImpl.suspend(AtmosphereResourceImpl.java:314) ~[atmosphere-runtime-2.1.2.vaadin2.jar:2.1.2.vaadin2]
    (...)

你对解决方案有什么想法吗?

EN

回答 2

Stack Overflow用户

发布于 2014-06-17 21:57:09

目前,只有在没有将WEBSOCKET设置为传输模式的情况下,Spring + Vaadin才能工作。尝试将其更改为长轮询或流:

代码语言:javascript
复制
@Push(transport = Transport.LONG_POLLING)

就我个人而言,我仍然对web应用程序使用旧的xml配置。以下是Vaadin 7的推送配置的一部分。

代码语言:javascript
复制
 <!-- Vaadin context -->
<servlet>
    <servlet-name>ISM Application</servlet-name>
    <servlet-class>org.vaadin.spring.servlet.SpringAwareVaadinServlet</servlet-class>
    <init-param>
        <param-name>closeIdleSessions</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:ism-web.xml</param-value>
    </init-param>
    <!-- Vaadin 7.1 @Push -->
    <init-param>
        <param-name>org.atmosphere.useWebSocketAndServlet3</param-name>
        <param-value>true</param-value>
    </init-param>
    <async-supported>true</async-supported>
</servlet>
票数 0
EN

Stack Overflow用户

发布于 2014-06-24 22:15:41

在看了下面的Vaadin网络研讨会后,我从服务器推送切换到了轮询,这解决了我的问题:

  • http://www.youtube.com/watch?v=GOKX-bGmi0k
  • http://www.youtube.com/watch?v=ZUshNi_4Gqc

下面的wiki介绍了如何使用轮询:

https://vaadin.com/wiki/-/wiki/Main/Using+polling

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24264442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档