users@grizzly.java.net

Re: Problem with Bayeux Servlet Client in GlassFish V3

From: Shing Wai Chan <Shing-Wai.Chan_at_Sun.COM>
Date: Tue, 09 Dec 2008 18:53:44 -0800

Hi,
I took a closer look at the issue in prelude.
Here is what I see:
1. Browser A accesses the echo application described in my blog
2. Browser B accesses the echo application described in my blog

Then I find that A and B can talk without issue.

3. Browser C accesses the API application as the one described below or
my blog

Both A and B does not get the message from C.
If A sends a message, then now, it will get the message from C and the
message just send,
But B will not get the the messge from C and the message just send by A.

But A and B can still talk without problem.
Look like there is a regression in this case even in prelude.
      Shing Wai Chan


Shing Wai Chan wrote:
> Hi,
>
> Do you see any errors in log in v3 Prelude?
> I am in GlassFish v3 trunk. When I deploy a grizzly-cometd-echo.war
> described in my blog
> and try to run it, I see the following:
>
> [#|2008-12-09T16:37:03.156-0800|SEVERE|glassfish|javax.enterprise.system.container.web|_ThreadID=17;_ThreadName=Thread-3;|StandardWrapperValve[Grizzly
> Cometd Servlet]: PWC1406: Servlet.service() for servlet Grizzly Cometd
> Servlet threw exception
> java.lang.ClassCastException:
> com.sun.grizzly.cometd.servlet.CometdServlet$1 cannot be cast to
> com.sun.grizzly.cometd.CometdResponse
> at
> com.sun.grizzly.cometd.servlet.CometdServlet.doPost(CometdServlet.java:97)
>
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
> at
> org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:465)
>
> at
> org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:464)
>
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:139)
>
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:186)
>
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
>
> at
> org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
>
> at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
> at
> com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98)
>
>
> Look like something is broken.
> Regards,
> Shing Wai Chan
>
> aalcamo wrote:
>> I am having a similar problem. I have installed the latest Glassfish v3
>> Prelude, and using Shing Wai's example to send messages via a servlet
>> to the
>> clients using the DeliverResponse object. I have spent many hours
>> trying to
>> upgrade to a later version of grizzly cometd but without success. My
>> code
>> seems to execute without exception now, but the clients do not get the
>> messages sent by the servlet. I'm testing using NetBeans6.5, and
>> several
>> MSIE7 clients. My 'broadcast message' code is below. Please let me
>> know if
>> there is any other info or files that I might provide. Thank you for
>> any
>> help.
>>
>> // code within my TestServlet.java
>> .
>> .
>>
>> protected void broadcast(HttpServletRequest request,
>> HttpServletResponse
>> response) throws ServletException, IOException {
>>
>> // joins add to the session map, leaves remove from the
>> session map
>> Map channelMap =
>> (Map)getServletContext().getAttribute("channellist");
>> if(request.getParameter("broadcast")!=null){
>>
>> String contextPath = "/dojoComet/cometd";
>> CometEngine engine = CometEngine.getEngine();
>> CometContext context = engine.getCometContext(contextPath);
>> DeliverResponse deliverResponse = new DeliverResponse();
>> ServletOutputStream out = response.getOutputStream();
>>
>> // IVR sends ID, type, call ID, and NIDs
>> //String id = request.getParameter("client");
>> String id="Carl"; // using canned value for now
>> double callID = 12345678901234567890D;
>> String type = "sales_exchange";
>> String nid = "48U";
>>
>> Map map = new HashMap();
>> map.put("id", id);
>> map.put("callID", callID);
>> map.put("type", type);
>> map.put("nid", nid);
>> Data data = new Data();
>> data.setMapData(map);
>>
>> Set keys = channelMap.keySet();
>> Iterator it = keys.iterator();
>> String key = null;
>> out.println("<html><body>");
>> while(it.hasNext()){
>> // just use the key since key name and channel are
>> same for
>> now
>> key = (String)channelMap.get(it.next());
>> deliverResponse.setChannel("/chat/"+key);
>> deliverResponse.setClientId(""); // fixes older
>> cometd bug
>> deliverResponse.setData(data);
>> deliverResponse.setLast(true);
>> deliverResponse.setFollow(true);
>> try{
>> context.notify(deliverResponse);
>> out.println("message sent to "+key+"<br/>");
>> }catch(IllegalMonitorStateException imse){
>> imse.printStackTrace();
>> }finally{
>> out.println("</body></html>");
>> }
>> }
>> }
>> }
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>