我试图获得primeface推送计数器示例。我认为我有正确的库,因为在服务器启动它显示我
nstalled AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy mapped to context-path /test1234 and Broadcaster Class org.atmosphere.cpr.DefaultBroadcaster
1732 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor [@PushEndpoint Interceptor] mapped to AtmosphereHandler org.primefaces.push.impl.PushEndpointHandlerProxy

并且根本没有错误。也没有其他输出。
谢谢大家的帮助, Duesentrieb
这里是文件:
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>pages</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<!-- context-param> <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value> </context-param -->
<!-- context-param> <param-name>primefaces.PUSH_SERVER_URL</param-name>
<param-value>http://127.0.0.1:8080</param-value> </context-param -->
<!-- PrimeFaces Configuration -->
<!-- <context-param> -->
<!-- <param-name>primefaces.THEME</param-name> -->
<!-- <param-value>Bootstrap</param-value> -->
<!-- </context-param> -->
<welcome-file-list>
<welcome-file>product/product.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<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.useNative</param-name> -->
<!-- <param-value>true</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.cpr.broadcasterClass</param-name> -->
<!-- <param-value>org.atmosphere.cpr.DefaultBroadcaster</param-value> -->
<!-- </init-param> -->
<!-- <init-param> -->
<!-- <param-name>org.atmosphere.cpr.CometSupport.maxInactiveActivity</param-name> -->
<!-- <param-value>1800000</param-value> -->
<!-- </init-param> -->
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/public/product/product.xhtml</location>
</error-page>
<filter>
<filter-name>AuthFilter</filter-name>
<filter-class>com.knightcnc.web.filter.AuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthFilter</filter-name>
<url-pattern>*.xhtml</url-pattern>
</filter-mapping>
</web-app>
&#13;
counter.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions">
<head>
</head>
<h:body>
<h:form id="form">
<h:outputText id="out" value="#{globalCounterView.count}"
styleClass="ui-widget display" />
<p:commandButton value="Click"
actionListener="#{globalCounterView.increment}" />
</h:form>
<p:socket onMessage="handleMessage" channel="/test1234" />
<script type="text/javascript">
function handleMessage(data) {
alert("Hola");
$('.display').html(data);
}
</script>
</h:body>
</html>
&#13;
GlobalCounterView.java
package test.primefaces.showcase.push.counter;
import java.io.Serializable;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import org.primefaces.push.EventBus;
import org.primefaces.push.EventBusFactory;
@ManagedBean
@ApplicationScoped
public class GlobalCounterView implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1234L;
private volatile int count;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public void increment() {
count++;
EventBus eventBus = EventBusFactory.getDefault().eventBus();
eventBus.publish("/test1234", String.valueOf(count));
}
}
&#13;
CounterRessource.java
package test.primefaces.showcase.push.counter;
import org.primefaces.push.EventBus;
import org.primefaces.push.RemoteEndpoint;
import org.primefaces.push.annotation.OnClose;
import org.primefaces.push.annotation.OnMessage;
import org.primefaces.push.annotation.OnOpen;
import org.primefaces.push.annotation.PushEndpoint;
import org.primefaces.push.impl.JSONEncoder;
@PushEndpoint("/test1234")
public class CounterResource {
@OnMessage(encoders = {JSONEncoder.class})
public String onMessage(String count) {
System.out.println("CounterResource.onMessage()");
return count;
}
@OnOpen
public void onOpen( RemoteEndpoint r, EventBus e ) {
System.out.println("Eventbus On Open");
}
@OnClose
public void onClose( RemoteEndpoint r, EventBus e ) {
System.out.println("Eventbus On Close");
}
}
&#13;
结束(因为字符限制在这里)控制台输出在第一次调用页面counter.xhtml
之后
...
AFTER_DEFAULT
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor Browser disconnection detection with priority AFTER_DEFAULT
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor org.atmosphere.interceptor.IdleResourceInterceptor with priority BEFORE_DEFAULT
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Using EndpointMapper class org.primefaces.push.impl.PushEndpointMapper
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Using BroadcasterCache: org.atmosphere.cache.UUIDBroadcasterCache
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Default Broadcaster Class: org.atmosphere.cpr.DefaultBroadcaster
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Broadcaster Shared List Resources: false
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Broadcaster Polling Wait Time 100
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Shared ExecutorService supported: true
1871 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Messaging ExecutorService Pool Size unavailable - Not instance of ThreadPoolExecutor
1872 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Async I/O Thread Pool Size: 200
1872 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Using BroadcasterFactory: org.atmosphere.cpr.DefaultBroadcasterFactory
1872 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Using AtmosphereResurceFactory: org.atmosphere.cpr.DefaultAtmosphereResourceFactory
1872 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Using WebSocketProcessor: org.atmosphere.websocket.DefaultWebSocketProcessor
1876 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Invoke AtmosphereInterceptor on WebSocket message true
1876 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - HttpSession supported: false
1876 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere is using DefaultAtmosphereObjectFactory for dependency injection and object creation
1876 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere is using async support: org.atmosphere.container.JSR356AsyncSupport running under container: Apache Tomcat/8.0.30 using javax.servlet/3.0 and jsr356/WebSocket API
1877 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Atmosphere Framework 2.3.5 started.
1877 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework -
For Atmosphere Framework Commercial Support, visit
http://www.async-io.org/ or send an email to support@async-io.org
1884 [localhost-startStop-1] INFO org.atmosphere.cpr.AtmosphereFramework - Installed AtmosphereInterceptor @PushEndpoint Interceptor with priority AFTER_DEFAULT
Dec 17, 2015 3:17:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Dec 17, 2015 3:17:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Dec 17, 2015 3:17:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4564 ms
2007 [Thread-3] INFO org.atmosphere.cpr.AtmosphereFramework - Latest version of Atmosphere's JavaScript Client 2.2.12
2007 [Thread-3] INFO org.atmosphere.cpr.AtmosphereFramework -
Atmosphere Framework Updates
Minor available (bugs fixes): 2.3.6
Major available (new features): 2.4.1.4
Dec 17, 2015 3:17:37 PM org.apache.myfaces.util.ExternalSpecifications isUnifiedELAvailable
INFO: MyFaces Unified EL support enabled
Dec 17, 2015 3:17:37 PM org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider newInstance
INFO: Creating instance of test.primefaces.showcase.push.counter.GlobalCounterView
&#13;