1 Reply Latest reply on Dec 15, 2011 1:07 PM by ronorato

    JBoss AS 7 Bayeux Support

    ronorato Newbie

      I am attempting to implement a bidirectional connection between my web client and my web server.  For this connection I am looking to use the Bayeux protocol.  From my previous post I have been informed that JBoss does have some level of support for the Bayeux protocol.  I have created a servlet that looks like ( some code has been removed ):

       

      @WebServlet(name="CometServlet", urlPatterns={"/cometd/*"},

                  initParams={@WebInitParam(name="timeout", value="60000")} )

      public class CometServlet extends HttpServlet implements HttpEventServlet

      {

        protected ArrayList<HttpServletResponse> connections   = new ArrayList<HttpServletResponse>();

       

        public CometServlet()

        {

          log.info( "CometServlet constructed" );

        }

       

        public void init()

         throws ServletException

        {

          log.info("init() entered");

        }

       

        public void destroy()

        {

          connections.clear();

        }

       

        public void event(HttpEvent event)

          throws IOException, ServletException

        {

          HttpServletRequest request = event.getHttpServletRequest();

          HttpServletResponse response = event.getHttpServletResponse();

             

          switch (event.getType()) {

            case BEGIN:

              synchronized(connections) {

                connections.add(response);

              }

              break;

            case ERROR:

              synchronized(connections) {

                connections.remove(response);

              }

              event.close();

              break;

            case END:

              synchronized(connections) {

                connections.remove(response);

              }

              event.close();

              break;

            case READ:

              break;

            default:

              log.warn("Unsupported Event Type: " + event.getType());

          }

        }

      }

       

      My client is sending the following Post:

      POST http://localhost:8080/myapp/cometd

       

      with the following parameter:

      message = [{"version":"1.0","minimumVersion":"0.9","channel":"/meta/handshake","id":"1","supportedConnectionTypes":["long-polling","long-polling-json-encoded","callback-polling"]}]

       

      what I am getting back is 405 - Method not allowed.  I am not seeing it hit the event method at all.

       

      Any help would be greatly appreciated.