I am trying to port an application that has been working fine with GlassFish
v2 to v3 but am encountering the following exception when trying to register
a topic with the comet engine.
java.lang.IllegalStateException: CometHandler cannot be null. This
CometHandler was probably resumed and an invalid reference was made to it.
at
com.sun.grizzly.comet.CometContext.<clinit>(CometContext.java:181)
at com.sun.grizzly.comet.CometEngine.register(CometEngine.java:284)
at com.sun.grizzly.comet.CometEngine.register(CometEngine.java:259)
at com.sun.grizzly.comet.CometEngine.register(CometEngine.java:244)
at com.test.MyServlet.init(MyServlet.java:63)
at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:14
28)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1060)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:187)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:188)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLock
ingStandardPipeline.java:85)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185
)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332
)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.
java:165)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
at
com.sun.grizzly.comet.CometEngine.executeServlet(CometEngine.java:473)
at com.sun.grizzly.comet.CometEngine.handle(CometEngine.java:341)
at
com.sun.grizzly.comet.CometAsyncFilter.doFilter(CometAsyncFilter.java:84)
at
com.sun.grizzly.arp.DefaultAsyncExecutor.invokeFilters(DefaultAsyncExecutor.
java:161)
at
com.sun.grizzly.arp.DefaultAsyncExecutor.interrupt(DefaultAsyncExecutor.java
:137)
at
com.sun.grizzly.arp.AsyncProcessorTask.doTask(AsyncProcessorTask.java:88)
at com.sun.grizzly.http.TaskBase.run(TaskBase.java:189)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.jav
a:330)
at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:3
09)
at java.lang.Thread.run(Thread.java:619)
Why is it trying to access the comet handler at this point? I haven't even
created one at this stage as I am just trying to initialise the servlet.
Here's the servlet's init() method where the problem is occurring:
public void init(ServletConfig config) throws
ServletException {
super.init(config);
ServletContext sc =
config.getServletContext();
String contextPath = sc.getContextPath() +
"/MyServlet";
cometContext =
CometEngine.getEngine().register(contextPath);
cometContext.setExpirationDelay(-1);
}
The relevant line is the call to register().
As I said, this has been working fine with GlassFish v2. The only changes I
made to port it to v3 were to change the import statements in all my
comet-related classes.
Why is this not working anymore? Do I need to change something else?
Thanks,
-JCT