Setting up primefaces push

UI Components for JSF
Post Reply
llper
Posts: 13
Joined: 24 Oct 2011, 14:40

24 Oct 2011, 15:04

Dear All,
I'm trying to setup prime-push on my web application, but I'm unable to figure out the correct steps.
I'm using primefaces 3.0.M4-SNAPSHOT on tomcat 6.0.26, under eclipse..
I've modified my server.xml adding the new connector:

Code: Select all

<Connector connectionTimeout="20000" port="6080" protocol="org.apache.coyote.http11.Http11NioProtocol" redirectPort="8443"/>
and I've modified my web.xml adding params and servlet:

Code: Select all

<context-param>
        <param-name>primefaces.PUSH_SERVER_URL</param-name>
     <!-- <param-value>ws://www.primefaces.org:9090/prime-pushserver</param-value> -->
   <param-value>ws://localhost:6080</param-value>
    </context-param>

	<servlet>
		<servlet-name>Atmosphere Servlet</servlet-name>
		<servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
		<init-param>
			<param-name>org.atmosphere.useWebSocket</param-name>
			<param-value>true</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.WebSocketProcessor</param-name>
			<param-value>org.atmosphere.cpr.HttpServletRequestWebSocketProcessor</param-value>
		</init-param>
		<init-param>
			<param-name>org.atmosphere.cpr.broadcastFilterClasses</param-name>
			<param-value>org.atmosphere.client.JavascriptClientFilter</param-value>
		</init-param>
		<load-on-startup>2</load-on-startup>
	</servlet>
	<servlet-mapping>
	  <servlet-name>Atmosphere Servlet</servlet-name>
	  <url-pattern>/prime-push/*</url-pattern>
	</servlet-mapping>
I've added all the required atmoshpere-0.X libraries to my build-path. In fact, when tomcat starts I can read:
  • Oct 24, 2011 2:36:40 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: Loaded APR based Apache Tomcat Native library 1.1.22.
    Oct 24, 2011 2:36:40 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
    Oct 24, 2011 2:36:40 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:InquisCRMJSF2' did not find a matching property.
    Oct 24, 2011 2:36:40 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
    WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context/Loader} Setting property 'useSystemClassLoaderAsParent' to 'false' did not find a matching property.
    Oct 24, 2011 2:36:41 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
    INFO: Using a shared selector for servlet write/read
    Oct 24, 2011 2:36:41 PM org.apache.coyote.http11.Http11NioProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-6080
    Oct 24, 2011 2:36:41 PM org.apache.coyote.ajp.AjpAprProtocol init
    INFO: Initializing Coyote AJP/1.3 on ajp-6009
    Oct 24, 2011 2:36:41 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 782 ms
    Oct 24, 2011 2:36:41 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Oct 24, 2011 2:36:41 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
    Oct 24, 2011 2:36:41 PM org.apache.catalina.core.StandardContext addApplicationListener
    INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
    Oct 24, 2011 2:36:42 PM com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing Mojarra 2.1.2 (FCS 20110613) for context '/InquisCRMJSF2'
    Oct 24, 2011 2:36:45 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
    INFO: Running on PrimeFaces 3.0.M4-SNAPSHOT
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.NotNull, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class org.hibernate.validator.constraints.NotEmpty, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.Size, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.Pattern, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.Min, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.Max, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.AssertTrue, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.javascript.ClientServiceConfigParser parse
    WARNING: Found JavaScript function definition for class javax.validation.constraints.AssertFalse, but that class is not presented
    Oct 24, 2011 2:36:45 PM org.richfaces.cache.CacheManager getCacheFactory
    INFO: Selected fallback cache factory
    Oct 24, 2011 2:36:45 PM org.richfaces.cache.lru.LRUMapCacheFactory createCache
    INFO: Creating LRUMap cache instance using parameters: {org.apache.myfaces.DETECT_JAVASCRIPT=false, org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS=true, org.apache.myfaces.PRETTY_HTML=true, org.apache.myfaces.RENDER_HIDDEN_FIELDS_FOR_LINK_PARAMS=false, org.apache.myfaces.WRAP_SCRIPT_CONTENT_WITH_XML_COMMENT_TAG=true, org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE=false, org.apache.myfaces.VIEWSTATE_JAVASCRIPT=false, org.apache.myfaces.SAVE_FORM_SUBMIT_LINK_IE=false, org.apache.myfaces.CONFIG_REFRESH_PERIOD=2, org.apache.myfaces.RENDER_CLEAR_JAVASCRIPT_FOR_BUTTON=false, org.apache.myfaces.RESOURCE_VIRTUAL_PATH=/faces/myFacesExtensionResource, org.apache.myfaces.ADD_RESOURCE_CLASS=org.apache.myfaces.renderkit.html.util.DefaultAddResource, javax.faces.PROJECT_STAGE=Development, com.sun.faces.enableMissingResourceLibraryDetection=true, org.apache.myfaces.RENDER_FORM_SUBMIT_SCRIPT_INLINE=false, org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS=auto, org.richfaces.enableControlSkinningClasses=false, org.apache.myfaces.AUTO_SCROLL=false, javax.faces.FACELETS_REFRESH_PERIOD=2, org.apache.myfaces.ALLOW_JAVASCRIPT=true, org.apache.myfaces.EXPRESSION_FACTORY=org.apache.el.ExpressionFactoryImpl, primefaces.PUSH_SERVER_URL=ws://localhost:6080, org.richfaces.enableControlSkinning=false, org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL=true, javax.servlet.jsp.jstl.fmt.localizationContext=resources.application, org.apache.myfaces.CHECK_EXTENSIONS_FILTER=true, org.apache.myfaces.VALIDATE_XML=false, org.apache.myfaces.STRICT_XHTML_LINKS=true, primefaces.THEME=aristo, javax.faces.STATE_SAVING_METHOD=server, javax.faces.DEFAULT_SUFFIX=.xhtml, org.apache.myfaces.RENDER_VIEWSTATE_ID=true}
    Oct 24, 2011 2:36:45 PM org.richfaces.cache.lru.LRUMapCacheFactory createCache
    INFO: Creating LRUMap cache instance of 512 items capacity
    Oct 24, 2011 2:36:45 PM org.richfaces.application.InitializationListener onStart
    INFO: RichFaces Core Implementation by JBoss, a division of Red Hat, Inc., version v.4.0.0.Final SVN r.22269
    Oct 24, 2011 2:36:45 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
    INFO: Monitoring jndi:/localhost/InquisCRMJSF2/WEB-INF/faces-config.xml for modifications
    14:36:46,008 INFO [AtmosphereServlet] Auto detecting atmosphere handlers in WEB-INF/classes
    14:36:46,106 INFO [AtmosphereServlet] Atmosphere is using async support: org.atmosphere.container.TomcatCometSupport running under container: Apache Tomcat/6.0.26
    14:36:46,121 INFO [AtmosphereServlet] Installed AtmosphereHandler null mapped to context-path: /*
    14:36:46,122 INFO [AtmosphereServlet] Using broadcaster class: org.atmosphere.cpr.DefaultBroadcaster
    14:36:46,124 INFO [AtmosphereServlet] Atmosphere Framework 0.8.0-RC1 started.
    Oct 24, 2011 2:36:46 PM org.apache.coyote.http11.Http11NioProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-6080
    Oct 24, 2011 2:36:46 PM org.apache.coyote.ajp.AjpAprProtocol start
    INFO: Starting Coyote AJP/1.3 on ajp-6009
    Oct 24, 2011 2:36:46 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 5142 ms
Anyway, when I go to the web application, firefox (and safari) are unable to connect to the websocket. I get, as an example in FF: Does anybody know how to solve the problem? Could someone post a full tutorial how to use primepush with the current 3.0 release please?

Thanks for any help,

llper

kiwifrog
Posts: 31
Joined: 03 Dec 2009, 15:01

22 Nov 2011, 16:24

The latest PF User guide has some basic instructions on how to set up Push:

"
Push Server

PrimeFaces Push uses a servlet as a dispatcher. This servlet should be in a different application than
the JSF application and at the moment can only be deployed on jetty server.

Code: Select all

<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>
channels configuration defines the topic names that push server can publish to.

URL Configuration
The JSF application needs to define the push server url to send messages.

Code: Select all

 <context-param>
  <param-name>primefaces.PUSH_SERVER_URL</param-name>
  <param-value>ws://url_to_push_server</param-value>
  </context-param>
"
--------------------------------
Using:
* Mojarra 2.1.3_01
* primefaces-3.0.M4
* Tomcat 7.0.14
Image

johngouf
Posts: 1
Joined: 28 Dec 2011, 01:18

28 Dec 2011, 01:20

Hi there!
Just a small question on the setting up. The server has to be Jetty, right? It doesn't work on Glassfish, is that correct?

drawinski
Posts: 2
Joined: 03 Aug 2011, 23:04

17 Feb 2012, 17:33

Hi!

We are trying to get Primefaces push working by setting up a standalone Jetty (jetty-distribution-8.1.0.v20120127).
We are using Tomcat 6.0.35 as a servlet container for our application.
Our web.xml contains the following:
<context-param>
<param-name>primefaces.PUSH_SERVER_URL</param-name>
<param-value>ws://localhost:8787/pushserver</param-value>
</context-param>

When we navigate to a page which contains a <p:push> tag on our JSF page it subscribes to the specified channel.
But when we try to push some message from a backing bean via RequestContext to Jetty the primefaces PushServlet's onMessage() method is never called.
So basically, we can not send a push message to Jetty.

Can you please provide a correct web.xml that we can deploy to our Jetty push server?
Any other advices are also welcome!

Thanks,
Andrew

Oslo
Posts: 4
Joined: 12 Feb 2016, 13:43

12 Feb 2016, 15:07

Dear Sirs,
I 'm struggling to get the Push Counter example to work.
Ref. Usergude 9. PrimeFaces Push: 9.1 Setup: See the copy from the manual in the lower part of the page:

The first part is refering to a pom.xml file in my application
Where shall I put this configuration when i dont have any pom.xml file?

Second part of the setup is a description of a dependency.
I guess these lines shall be in the WEB-INF/LIB/web.xml, but the <async-supported>true</async-supported> fails with: Invalid content was found starting with element 'async-supported'.

The libraryfiles atmosphere-runtime 2.4.2.jar and atmosphere-compat7-2.0.1.jar is in the projects library.

When I run the application and then press the Button for incrementing it appears a list of faultmessages which starts with the following faultmessage:

SEVERE: java.lang.NoClassDefFoundError: org/atmosphere/cpr/BroadcasterListener
at org.primefaces.push.EventBusFactory.<init>(EventBusFactory.java:26)
at org.primefaces.push.EventBusFactory.<clinit>(EventBusFactory.java:25)
at com.stnett.Push.GlobalCounterView.increment(GlobalCounterView.java:32)


Question No1: What shall i write where to get the examole Counter to work?
Question No2: Do I need to add some libraryfiles to the Tomcat-installation? I suppose NOT.

Difficult to find information about this in the documentation for Atmosphere and Tomcat as well.

Regards
-Gunnar :shock:

Using PF ver. 5.1
Tomcat ver. 7.0
RichFaces ver. 4.2
JSF2.0

Copy from the PF User Manual:

Atmosphere
Atmosphere is required to run PrimeFaces Push, in your pom.xml define the dependency as;
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.3.RC6 or newer</version>
</dependency>


Push Servlet
Push Servlet is used as a gateway for clients.
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>

Miguel Cubells
Posts: 99
Joined: 25 Feb 2015, 11:02

01 Mar 2016, 07:33

the <async-supported>true</async-supported> fails with: Invalid content was found starting with element 'async-supported'
Make sure you are using a servlet 3.0 compatible web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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">
Also, for Tomcat 7, you may need to use the atmosphere-runtime-native dependency, instead of the [atmosphere-runtime]

It works for me.
PrimeFaces 6.1 / PF Extensions 6.1.1 / Atmosphere 2.4.3
Apache Mojarra 2.2.13+
WildFly 10.1.0.Final

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests