PrimePush在Tomcat 7上不起作用



我是PrimePush的新手,并且有一个问题。整个项目基于Maven,服务器是Tomcat 7.0.27,因此我将依赖性添加到pom.xml文件中:

    <dependency>
         <groupId>org.atmosphere</groupId>
          <artifactId>atmosphere-runtime</artifactId>
           <version>1.0.1</version>
      </dependency>
      <dependency>
         <groupId>org.atmosphere</groupId>
         <artifactId>atmosphere-annotations</artifactId>
         <version>1.0.1</version>
      </dependency>

web.xml就像以下:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    <init-param>
        <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
        <param-value>org.atmosphere.cache.HeaderBroadcasterCache</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.broadcasterClass</param-name>
        <param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
        <param-value>org.atmosphere.client.TrackMessageSizeFilter</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.sessionSupport</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
       <param-name>org.atmosphere.useWebSocket</param-name>
    <param-value>false</param-value>
</init-param>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping> 

我从PrimeFaces Showcase获取聊天代码,但是某种程度上,Atomsphereframework的IllegalStateException始终被抛出。

    09:33:38.322 ERROR o.atmosphere.cpr.AtmosphereFramework - AtmosphereFramework exception
java.lang.IllegalStateException: Not supported.
   at org.apache.catalina.connector.Request.startAsync(Request.java:1609) ~[catalina.jar:7.0.12]
   at org.apache.catalina.connector.RequestFacade.startAsync(RequestFacade.java:1031) ~[catalina.jar:7.0.12]
   at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:379) ~[servlet-api.jar:3.0.FR]
   at javax.servlet.ServletRequestWrapper.startAsync(ServletRequestWrapper.java:379) ~[servlet-api.jar:3.0.FR]
   at org.atmosphere.cpr.AtmosphereRequest.startAsync(AtmosphereRequest.java:556) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
   at org.atmosphere.container.Servlet30CometSupport.suspend(Servlet30CometSupport.java:137) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
   at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:103) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
   at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:1293) ~[atmosphere-runtime-1.0.1.jar:1.0.1]
   at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:293) [atmosphere-runtime-1.0.1.jar:1.0.1]
   at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:279) [atmosphere-runtime-1.0.1.jar:1.0.1]
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [servlet-api.jar:na]

我调试Atomsphere框架的源代码,并找出问题是Servlet30CometSupport.class中的以下行:

AsyncContext asyncContext = req.startAsync(req, res);

之后,它引发了一个非法的Exception。我该如何解决这个问题?感谢您的任何帮助

tomcat版本7.0.27支持Websockets。因此,您的Web.xml中的参数设置应为

<init-param>
    <param-name>org.atmosphere.useWebSocket</param-name>
    <param-value>true</param-value>
</init-param>

或省略整个参数设置原因Websockets默认使用。

您还需要添加大气组合 - tomcat-tomcat-1.0.1.jar和大气 - compat-tomcat7-1.0.1.1.jar

的依赖项。

相关内容

  • 没有找到相关文章

最新更新