Primefaces聊天应用程序 - web.xml从element开始找到无效的内容

时间:2013-04-25 14:12:52

标签: java primefaces chat tomcat7 web.xml

我想在tomcat 7服务器上实现PF 3.5 Chat Application。我添加了依赖项:

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

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.1</version>
</dependency>

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.1</version>
</dependency>

但是,当我实施web.xml时:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

...

<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>
</servlet>
<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

作为一个赘述,我得到了:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'init-param'. One of '{"http://java.sun.com/
 xml/ns/javaee":run-as, "http://java.sun.com/xml/ns/javaee":security-role-ref}' is expected.

btw我在<init-param>标签处获得了例外。

我非常感谢你的回答!

更新

当我写这篇文章时,我得到同样的赘述:

<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>channels</param-name>
        <param-value>chat,counter</param-value>
    </init-param>
</servlet>

<servlet-mapping>
    <servlet-name>Push Servlet</servlet-name>
    <url-pattern>/prime-push/*</url-pattern>
</servlet-mapping>

我也在<init-param>代码

处获得了展示

2 个答案:

答案 0 :(得分:20)

根据schema命令的重要性。因此<load-on-startup/>元素应位于<init-param/>元素之后。

例如

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <init-param>
        <param-name>channels</param-name>
        <param-value>chat,counter</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

答案 1 :(得分:2)

确实,订单很重要,对于PF Push Servlet&amp;氛围这个设置是一个很好的起点:

<servlet>
    <servlet-name>Push Servlet</servlet-name>
    <servlet-class>org.primefaces.push.PushServlet</servlet-class>
    <init-param>
    <param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
    <param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.broadcaster.maxProcessingThreads</param-name>
        <param-value>15</param-value>
    </init-param>
    <init-param>
        <param-name>org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads</param-name>
        <param-value>15</param-value>
    </init-param>
    <load-on-startup>0</load-on-startup>
    <async-supported>true</async-supported>
</servlet>