I am trying to run Grizzly Comet program on embedded GlassFish. The code to start up the server is shown below.
EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
efsb.instanceRoot( new File("D:/Program/netbeans-projects/EmGlassfish/GlassFishRoot") );
EmbeddedFileSystem efs = efsb.build();
Server.Builder builder = new Server.Builder("CometServer");
builder.embeddedFileSystem(efs);
builder.verbose(true);
Server server = builder.build();
ContainerBuilder containerBuilder = server.createConfig(ContainerBuilder.Type.web);
server.addContainer(containerBuilder);
EmbeddedWebContainer webContainer = (EmbeddedWebContainer)containerBuilder.create(server);
Port http = server.createPort(8080);
webContainer.bind(http, "httpPort");
deployWar(server);
server.start();
When I ran the program, I got exception:
Sep 15, 2010 6:05:41 PM org.apache.catalina.core.StandardWrapperValve log
WARNING: StandardWrapperValve[CometTest]: PWC1406: Servlet.service() for servlet CometTest threw exception
java.lang.IllegalStateException: Make sure you have enabled Comet or make sure the Thread invoking that method is the same as the Servlet.service() Thread.
at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:286)
at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:305)
at com.reuters.sds.comet.CometTest.processRequest(CometTest.java:82)
at com.reuters.sds.comet.CometTest.doGet(CometTest.java:106)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1522)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
I recall this is the exception of GlassFish server hasn't been set to enable comet support. Could anyone tell me how to enable the configuration problematically.
[Message sent by forum member 'devguli']
http://forums.java.net/jive/thread.jspa?messageID=482817