CometContext question

UI Components for JSF
Post Reply
jguerra
Posts: 51
Joined: 26 Aug 2009, 13:03
Contact:

22 Jan 2010, 13:21

Hi all,
Just a couple lines to hopefully get some help about an hypotetical application using Comet with primefaces.
The whole idea is to try to get working a application using the <p:outputpanel> component and a long term background thread living a controller and pushing data into this component. I got something working but I loose the CometContext. How can i manage to keep the CometContext alive in another class?. Can anyone around here please shed more light in how to get working something like that?

Code: Select all

public void startMonitor(ActionEvent event) {
		CometContext.publish("ack", "Wellcome to Foo monitor." );   // It works!

		Runnable r = new Runnable(){

			@Override
			public void run() {
				while (true) {
					CometContext.publish("ack", new Date());  // It doesn't work, CometContext is null.
					try {
						TimeUnit.SECONDS.sleep(1);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
				
			}};
		new Thread(r).start();	
	}
Thanks in advance!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

22 Jan 2010, 19:03

CometContext is not supposed to be initialized so I don't get how it can be null as you call if staticly. Do you get an exception? If so what's the stack trace?

jguerra
Posts: 51
Joined: 26 Aug 2009, 13:03
Contact:

23 Jan 2010, 14:45

Hi
Thanks for your reply. Ok, tomcat console output was:

WARNING: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
Enable it or if enabled add the following content under your META-INF/context.xml of your war file.
<Context> <Loader delegate="true"/> </Context>
23-Jan-2010 12:27:09 org.atmosphere.cpr.AtmosphereServlet doCometSupport
WARNING: Using the BlockingIOCometSupport.
Exception in thread "Thread-8" java.lang.NullPointerException
at org.primefaces.comet.CometContext.publish(CometContext.java:37)
console.VMECommandACKController$1.run(VMECommandACKController.java:35)
at java.lang.Thread.run(Thread.java:619)


line 35 is:

Code: Select all

  CometContext.publish("ack", new Date());  // It doesn't work, CometContext is null.
Regarding the tomcat log, I can't get rid of that warning. context.xml file is in place and http11NioProtocol is enabled on server.xml.

Tomcat Version: 6.0.20/24

Thanks

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

25 Jan 2010, 18:39

Can't really understand how CometContext can be null, we access it staticly, it's not initializd anyway.

Can you post related nioprotocol settings in your server.xml so we can be sure, tomcat nio connector is enabled.

jguerra
Posts: 51
Joined: 26 Aug 2009, 13:03
Contact:

25 Jan 2010, 21:43

Thanks for being so proactive on the forum. As you see below, protocol is set up in server.xml as follows:

Code: Select all

 <Connector connectionTimeout="20000" port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" redirectPort="8443"/>
Tomcat console output is:

Jan 25, 2010 7:29:34 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/server:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/../lib/i386:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386/client:/usr/lib/jvm/java-6-sun-1.6.0.16/jre/lib/i386:/usr/lib/xulrunner-addons:/usr/lib/xulrunner-addons:/usr/java/packages/lib/i386:/lib:/usr/lib
Jan 25, 2010 7:29:34 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:TrackingConsole' did not find a matching property.
Jan 25, 2010 7:29:34 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Jan 25, 2010 7:29:34 PM org.apache.coyote.http11.Http11NioProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Jan 25, 2010 7:29:34 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1064 ms
Jan 25, 2010 7:29:34 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Jan 25, 2010 7:29:34 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Jan 25, 2010 7:29:35 PM org.primefaces.optimus.listener.ContextListener contextInitialized
INFO: Initializing Optimus Context
Jan 25, 2010 7:29:36 PM org.primefaces.optimus.listener.ContextListener contextInitialized
INFO: Optimus JPA persistence support is disabled
Jan 25, 2010 7:29:36 PM org.primefaces.optimus.listener.ContextListener contextInitialized
INFO: Optimus Context initialized successfully
Jan 25, 2010 7:29:36 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra (1.2_12-b01-FCS) for context '/TrackingConsole'
Jan 25, 2010 7:29:37 PM org.atmosphere.cpr.AtmosphereServlet loadConfiguration
WARNING: Missing META-INF/atmosphere.xml. Will try to autodetect AtmosphereHandler
Jan 25, 2010 7:29:37 PM org.atmosphere.cpr.AtmosphereServlet autoDetectAtmosphereHandlers
INFO: Atmosphere using Broadcaster org.atmosphere.cpr.DefaultBroadcaster
Jan 25, 2010 7:29:37 PM org.atmosphere.cpr.AtmosphereServlet autoDetectContainer
INFO: Atmosphere is using for CometSupport: org.atmosphere.container.TomcatCometSupport running under container Apache Tomcat/6.0.24
Jan 25, 2010 7:29:37 PM org.atmosphere.cpr.AtmosphereServlet init
INFO: Atmosphere Framework 0.5-SNAPSHOT started.
log4j:WARN No appenders could be found for logger (org.apache.axis.transport.http.AxisServlet).
log4j:WARN Please initialize the log4j system properly.
Jan 25, 2010 7:29:38 PM org.apache.coyote.http11.Http11NioProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Jan 25, 2010 7:29:39 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Jan 25, 2010 7:29:39 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/87 config=null
Jan 25, 2010 7:29:39 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4411 ms
Jan 25, 2010 7:29:40 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/facestrace-1.1.1-SNAPSHOT.jar!/META-INF/facestrace.taglib.xml
Jan 25, 2010 7:29:40 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-facelets-1.1.14.jar!/META-INF/jsf-core.taglib.xml
Jan 25, 2010 7:29:40 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-facelets-1.1.14.jar!/META-INF/jsf-html.taglib.xml
Jan 25, 2010 7:29:40 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-facelets-1.1.14.jar!/META-INF/jsf-ui.taglib.xml
Jan 25, 2010 7:29:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-facelets-1.1.14.jar!/META-INF/jstl-core.taglib.xml
Jan 25, 2010 7:29:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-facelets-1.1.14.jar!/META-INF/jstl-fn.taglib.xml
Jan 25, 2010 7:29:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/jsf-impl-1.2_12.jar!/META-INF/mojarra_ext.taglib.xml
Jan 25, 2010 7:29:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/primefaces-1.0.0-SNAPSHOT.jar!/META-INF/primefaces-p.taglib.xml
Jan 25, 2010 7:29:41 PM com.sun.facelets.compiler.TagLibraryConfig loadImplicit
INFO: Added Library from: jar:file:/home/guerra/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/TrackingConsole/WEB-INF/lib/primefaces-1.0.0-SNAPSHOT.jar!/META-INF/primefaces-i.taglib.xml
Jan 25, 2010 7:30:14 PM org.atmosphere.cpr.AtmosphereServlet doCometSupport
WARNING: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
Enable it or if enabled add the following content under your META-INF/context.xml of your war file.
<Context> <Loader delegate="true"/> </Context>
Jan 25, 2010 7:30:14 PM org.atmosphere.cpr.AtmosphereServlet doCometSupport
WARNING: Using the BlockingIOCometSupport.
Exception in thread "Thread-8" java.lang.NullPointerException
at org.primefaces.comet.CometContext.publish(CometContext.java:37)
at console.VMECommandACKController$1.run(VMECommandACKController.java:33)
at java.lang.Thread.run(Thread.java:619)


Ps, note that line 33 is

Code: Select all

CometContext.publish("ack", new Date());
Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 47 guests