Hello Richard,
Thanx much for all your pointers. I hadn't realized that you had replied to my post until this morning. I am still getting use to getting around in the forum.
Apologies for the belated response. Your contributions were very helpful to me. I believe I have the mechanics of this technique down, I just needed clarifications on implementation.
Best Regards,
Hiram
From: Hiram Coffy
Sent: Thursday, October 30, 2008 4:23 PM
To: 'users_at_grizzly.dev.java.net'
Subject: RE: Problem with comet-based web app
Salut Jeanfrancois,
Thank you very much for being so responsive. Your answers to step 2 and 6 got me unstuck. I appreciate your help.
2) API: What compatible comet api should I compile the source code against?
If you plan to deploy against v2ur2, you need to build against the API
that ship with v2. Hence, in your classpath, you need to add:
${glassfish.home}/lib/appserv-rt.jar.
6)Last question: Does the app server come bundled with the comet api
yes, in v2: com.sun.enterprise.web.connector.grizzly.comet.*
in v3 and grizzly standalone: com.sun.grizzly.comet
Keep up the great work!
Regards,
Hiram
A+
From: Hiram Coffy
Sent: Wednesday, October 29, 2008 12:57 PM
To: 'users_at_grizzly.dev.java.net'
Subject: Re: Problem with comet-based web app
Hi all,
I am still struggling with getting my comet-based servlet to work. Any help would be much appreciated
I guess what would be helpful for me is a simple step-by-step procedure. So far, what I have found is scattered and fragmented bits and pieces of information, critical details appear to be glossed over.
I suppose I can boil down my request to the following set of questions:
1) APP SERVER: What do I need to get comet-based servlet working? e.g. glassfish V2UR2 with comet support enabled.
2) API: What compatible comet api should I compile the source code with?
3) API DOWNLOAD: Where do I download the API from?
4) CLASSPATH: Do I copy the API to ${as.home}/lib for example
5) TEST: How do I positively verify that comet support is indeed enabled?
6)Last question: Does the app server come bundled with the comet api
From: Hiram Coffy
Sent: Sunday, October 26, 2008 5:39 PM
To: 'users_at_grizzly.dev.java.net'
Subject: Problem with comet-based web app
Hello Jean-Francois,
Let me start by thanking you for all your good work on the Grizzly/comet front. Kudos!
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.
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?