Sun GlassFish Enterprise Server v3 Application Development Guide

ProcedureTo Configure the web.xml File

To enable the Bayeux protocol on the Enterprise Server, you must reference the CometdServlet in your web application's web.xml file. In addition, if your web application includes a servlet, set the load-on-startup value for your servlet to 0 (zero) so that it will not load until the client makes a request to it.

  1. Open the web.xml file for your web application in a text editor.

  2. Add the following XML code to the web.xml file:

    <servlet>
       <servlet-name>Grizzly Cometd Servlet</servlet-name>
       <servlet-class>
          com.sun.grizzly.cometd.servlet.CometdServlet
       </servlet-class>
       <init-param>
          <description>
             expirationDelay is the long delay before a request is
             resumed. -1 means never.
          </description>
          <param-name>expirationDelay</param-name>
          <param-value>-1</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
       <servlet-name>Grizzly Cometd Servlet</servlet-name>
       <url-pattern>/cometd/*</url-pattern>
    </servlet-mapping>

    Note that the load-on-startup value for the CometdServlet is 1.

  3. If your web application includes a servlet, set the load-on-startup value to 0 for your servlet (not the CometdServlet) as follows:

    <servlet>
       ...
       <load-on-startup>0</load-on-startup>
    </servlet>
  4. Save the web.xml file.