推送不可用

Push is not available

我有一个奇怪的问题,我想简单描述一下。我正在开发一个需要启用推送模式的 Vaadin 应用程序。我正在使用 jetty(7.4.2.v20110526) 之类的应用程序服务器来开发。 现在,如果我尝试 运行 我的应用程序 web.xml:

<servlet>
    <servlet-name>Vaadin Application Servlet</servlet-name>
    <servlet-class>ru.xpoft.vaadin.SpringVaadinServlet</servlet-class>
    <init-param>
        <param-name>beanName</param-name>
        <param-value>MyVaadinUI</param-value>
    </init-param>
    <init-param>
        <description>Application widgetset</description>
        <param-name>widgetset</param-name>
        <param-value>it.myapp.view.AppWidgetSet</param-value>
    </init-param>
     <!-- Enable server push -->
    <init-param>
        <param-name>pushmode</param-name>
        <param-value>automatic</param-value>
    </init-param>
     <!-- 
    <init-param>
        <param-name>org.atmosphere.cpr.asyncSupport</param-name>
        <param-value>org.atmosphere.container.JSR356AsyncSupport</param-value>
    </init-param> 
    -->
    <async-supported>true</async-supported>
</servlet>

一切正常,当我尝试启用 asyncSupport 参数时,我得到以下堆栈跟踪:

    [http-nio-8080-exec-2] 11:42:43,925 ERROR com.vaadin.server.DefaultErrorHandler.doDefault(DefaultErrorHandler.java:59) - 
java.lang.IllegalStateException: Push is not available. See previous log messages for more information.
    at com.vaadin.ui.PushConfigurationImpl.setPushMode(PushConfiguration.java:184)
    at com.vaadin.server.communication.UIInitHandler.getBrowserDetailsUI(UIInitHandler.java:212)
    at com.vaadin.server.communication.UIInitHandler.synchronizedHandleRequest(UIInitHandler.java:74)
    at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
    at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1405)
    at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
    at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

这是我的依赖关系树:

    [INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ SchedulerView ---
[INFO] it.scheduler.view:SchedulerView:war:1.0
[INFO] +- com.vaadin:vaadin-server:jar:7.4.0:compile
[INFO] |  +- com.vaadin:vaadin-sass-compiler:jar:0.9.12:compile
[INFO] |  \- org.jsoup:jsoup:jar:1.8.1:compile
[INFO] +- com.vaadin:vaadin-client:jar:7.4.0:compile
[INFO] |  +- org.w3c.css:sac:jar:1.3:compile
[INFO] |  +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] |  \- javax.validation:validation-api:jar:sources:1.0.0.GA:compile
[INFO] +- com.vaadin:vaadin-shared:jar:7.4.0:compile
[INFO] |  +- com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile
[INFO] |  +- com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:jar:0.0.10.vaadin1:compile
[INFO] |  \- com.vaadin.external.google:guava:jar:16.0.1.vaadin1:compile
[INFO] +- com.vaadin:vaadin-client-compiled:jar:7.4.0:compile
[INFO] +- com.vaadin:vaadin-client-compiler:jar:7.4.0:compile
[INFO] |  +- ant:ant:jar:1.6.5:compile
[INFO] |  +- net.sourceforge.cssparser:cssparser:jar:0.9.11:compile
[INFO] |  +- ant:ant-launcher:jar:1.6.5:compile
[INFO] |  +- org.ow2.asm:asm:jar:5.0.3:compile
[INFO] |  +- org.ow2.asm:asm-util:jar:5.0.3:compile
[INFO] |  |  \- org.ow2.asm:asm-tree:jar:5.0.3:compile
[INFO] |  +- org.ow2.asm:asm-commons:jar:5.0.3:compile
[INFO] |  +- org.eclipse.jetty:jetty-annotations:jar:8.1.12.v20130726:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-plus:jar:8.1.12.v20130726:compile
[INFO] |  |  |  +- org.eclipse.jetty.orbit:javax.transaction:jar:1.1.1.v201105210645:compile
[INFO] |  |  |  \- org.eclipse.jetty:jetty-jndi:jar:8.1.12.v20130726:compile
[INFO] |  |  |     +- org.eclipse.jetty:jetty-server:jar:8.1.12.v20130726:compile
[INFO] |  |  |     |  \- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:compile
[INFO] |  |  |     \- org.eclipse.jetty.orbit:javax.mail.glassfish:jar:1.4.1.v201005082020:compile
[INFO] |  |  |        \- org.eclipse.jetty.orbit:javax.activation:jar:1.1.0.v201105071233:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-webapp:jar:8.1.12.v20130726:compile
[INFO] |  |  |  +- org.eclipse.jetty:jetty-xml:jar:8.1.12.v20130726:compile
[INFO] |  |  |  \- org.eclipse.jetty:jetty-servlet:jar:8.1.12.v20130726:compile
[INFO] |  |  |     \- org.eclipse.jetty:jetty-security:jar:8.1.12.v20130726:compile
[INFO] |  |  +- org.eclipse.jetty.orbit:javax.annotation:jar:1.1.0.v201108011116:compile
[INFO] |  |  \- org.eclipse.jetty.orbit:org.objectweb.asm:jar:3.1.0.v200803061910:compile
[INFO] |  +- org.eclipse.jetty:jetty-servlets:jar:8.1.12.v20130726:compile
[INFO] |  |  +- org.eclipse.jetty:jetty-continuation:jar:8.1.12.v20130726:compile
[INFO] |  |  \- org.eclipse.jetty:jetty-client:jar:8.1.12.v20130726:compile
[INFO] |  |     \- org.eclipse.jetty:jetty-http:jar:8.1.12.v20130726:compile
[INFO] |  |        \- org.eclipse.jetty:jetty-io:jar:8.1.12.v20130726:compile
[INFO] |  +- org.eclipse.jetty:jetty-util:jar:8.1.12.v20130726:compile
[INFO] |  +- org.jdesktop:swing-worker:jar:1.1:compile
[INFO] |  +- commons-codec:commons-codec:jar:1.8:compile
[INFO] |  +- commons-io:commons-io:jar:2.4:compile
[INFO] |  +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] |  +- org.apache.james:apache-mime4j:jar:0.6:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.3.1:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.3.1:compile
[INFO] |  +- net.sourceforge.nekohtml:nekohtml:jar:1.9.19:compile
[INFO] |  +- xalan:serializer:jar:2.7.1:compile
[INFO] |  +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] |  +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] |  +- com.ibm.icu:icu4j:jar:50.1.1:compile
[INFO] |  \- com.vaadin:vaadin-client-compiler-deps:jar:1.2.0:compile
[INFO] +- com.vaadin:vaadin-themes:jar:7.4.0:compile
[INFO] +- com.vaadin:vaadin-push:jar:7.4.0:compile
[INFO] |  \- com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.4.vaadin2:compile
[INFO] |     \- com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile
[INFO] +- com.vaadin:vaadin-theme-compiler:jar:7.1.15:compile
[INFO] |  +- org.apache.commons:commons-jexl:jar:2.1.1:compile
[INFO] |  \- commons-cli:commons-cli:jar:1.2:compile
[INFO] +- ru.xpoft.vaadin:spring-vaadin-integration:jar:3.1:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.7:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.7:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.2:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.1.2:compile
[INFO] +- org.springframework:spring-web:jar:3.2.11.RELEASE:compile
[INFO] |  \- org.springframework:spring-aop:jar:3.2.11.RELEASE:compile
[INFO] |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.2.11.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.4:provided
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.1:compile
[INFO] |  \- c3p0:c3p0:jar:0.9.1.1:compile
[INFO] +- org.quartz-scheduler:quartz-jobs:jar:2.2.1:compile
[INFO] +- it.scheduler:schedulerdomain:jar:0.0.1-SNAPSHOT:compile
[INFO] |  +- org.postgresql:postgresql:jar:9.4-1201-jdbc41:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-jdbc:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-orm:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-tx:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.springframework:spring-aspects:jar:3.2.11.RELEASE:compile
[INFO] |  |  \- org.aspectj:aspectjweaver:jar:1.7.4:compile
[INFO] |  +- org.springframework:spring-test:jar:3.2.11.RELEASE:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:4.2.4.Final:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.1.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] |  |  +- org.hibernate.common:hibernate-commons-annotations:jar:4.0.2.Final:compile
[INFO] |  |  \- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] |  +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  +- org.hibernate:hibernate-validator:jar:4.3.1.Final:compile
[INFO] |  |  \- org.jboss.logging:jboss-logging:jar:3.1.0.CR2:compile
[INFO] |  +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] |  +- cglib:cglib:jar:3.1:compile
[INFO] |  \- javassist:javassist:jar:3.12.1.GA:compile
[INFO] \- javax.websocket:javax.websocket-api:jar:1.1:compile

我哪里做错了?

更新 1

我看到了之前的日志信息:

    [http-nio-8080-exec-10] 11:42:43,406 WARN  com.vaadin.server.VaadinServletService.ensurePushAvailable(VaadinServletService.java:296) - 
=================================================================
Atmosphere could not be loaded. When using push with Vaadin, the
Atmosphere framework must be present on the classpath.
If using a dependency management system, please add a dependency
to vaadin-push.
If managing dependencies manually, please make sure Atmosphere
2.1.2.vaadin2 is included on the classpath.
Will fall back to using PushMode.DISABLED.
=================================================================

但似乎一切正常

你的servlet版本是2.4

[INFO] +- javax.servlet:servlet-api:jar:2.4:provided

不过,异步处理好像是servlet 3.0引入的,servlet好像没有2.x

Asynchronous processing support in Servlet 3.0

Vaadin Push Enabling

我建议您更新您的 servlet 版本。使用 servlet 3.0,您甚至不需要 web.xml 文件来配置推送或其他属性。您只需在 UI class 中使用注释即可。