users@grizzly.java.net

Re: Problem with comet-based web app

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Mon, 27 Oct 2008 09:30:21 -0400

Salut,

Hiram Coffy wrote:
> Hello Jean-Francois,
> Let me start by thanking you for all your good work on the Grizzly/comet
> front. Kudos!

Thanks! And thanks for posting the issue here (I saw you post on my blog).


>
> I wrote a simple comet app based on the tutorial found at:
> http://docs.sun.com/app/docs/doc/820-4496/ggrgt?a=view.
>
> I get the following exception when a request is received by my servlet:
> java.lang.IllegalStateException: Make sure you have enabled Comet or
> make sure the Thread invoking that method is the same a the request Thread.
> at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:263)
> at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:311)
> ....
>
> I have already combed through your blogs. I have tried all the
> suggestions that I have come across. So far, i haven't had any success.
> I noticed a peculiar behavior with my glassfish instance; whether
> <property name="cometSupport" value="true"/> is added to domain.xml or
> not seems to make not a bit of a difference.

Hum...can you post me your war file so I can take a look?


>
> I have made sure to bounce the server every time i make a change to
> domain.xml to ensure that the changes will be recognized. I have tried
> several experiments with the "cometSupport" property added and removed
> from domain.xml. I ave tried similar experiments with <property
> name="proxiedProtocols" value="ws/tcp"/> I have even enabled the flag
> through the command line using "asadmin set
> server.http-service.http-listener.http-listener-1.property.cometSupport=true"
>
> Relevant environment information:
> Sun Java System Application Server 9.1 (build b58g-fcs) (GlassfishV2)
>
> excerpt from domain.xml:
> ....
> <http-listener acceptor-threads="1" address="0.0.0.0"
> blocking-enabled="false" default-virtual-server="server" enabled="true"
> family="inet" id="http-listener-1" port="8080" security-enabled="false"
> server-name="" xpowered-by="true">
> <property name="proxiedProtocols" value="ws/tcp"/>
> <property name="cometSupport" value="true"/>
> </http-listener>
> ....
>
> excerpt from app server output console:
> ....
> WEB0302: Starting Sun-Java-System/Application-Server.
> Enabling Grizzly ARP Comet support.
> WEB0712: Starting Sun-Java-System/Application-Server HTTP/1.1 on 8080
> ....
>
> excerpt from web.xml
> ...
> <servlet>
> <servlet-name>RefreshServlet</servlet-name>
> <servlet-class>package.RefreshServlet</servlet-class>
> <load-on-startup>0</load-on-startup>
> </servlet>
> ...
>
> The following bit of code registers the handler and is invoked only
> once, upon receipt of first request.
> private void registerHandler(HttpServletResponse response)
> throws IllegalStateException{
> if (oneShot) {
> RefreshHandler handler = new RefreshHandler();
> handler.attach(response);
>
> CometEngine engine = CometEngine.getEngine();
> CometContext context = engine.getCometContext(contextPath);
>
> try{
> context.addCometHandler(handler);
> oneShot = false;
> }catch(IllegalStateException ex){
> logger.error(ex.getMessage(), ex);
> throw ex;
> }
> }
> }
> Two questions:
> 1) Any suggestions?
> 2) How can I positively tell that comet support is indeed enabled?

What is the value of the contextPath? (Just curious). I don't see
anything wrong with your description. If you can, just send me you app
and I will take a look.

Thanks!

-- Jeanfrancois



>
>
>