我收到以下错误

#|2010-10-31T19:13:38.127+0530|SEVERE|glassfish|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=Thread-3;|StandardWrapperValve[Grizzly Cometd Servlet]: PWC1406: Servlet.service() for servlet Grizzly Cometd Servlet threw exception
java.lang.IllegalStateException: Make sure you have enabled Comet or make sure the Thread invoking that method is the same a the request Thread.
 at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:263)
 at com.sun.grizzly.cometd.servlet.CometdServlet.doPost(CometdServlet.java:159)
 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:431)
 at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
 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)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
 at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
 at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
 at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
 at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
 at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
 at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
|#]

[#|2010-10-31T19:14:51.754+0530|SEVERE|glassfish|javax.enterprise.system.container.web|_ThreadID=15;_ThreadName=Thread-3;|StandardWrapperValve[Grizzly Cometd Servlet]: PWC1406: Servlet.service() for servlet Grizzly Cometd Servlet threw exception
java.lang.IllegalStateException: Make sure you have enabled Comet or make sure the Thread invoking that method is the same a the request Thread.
 at com.sun.grizzly.comet.CometContext.addCometHandler(CometContext.java:263)
 at com.sun.grizzly.cometd.servlet.CometdServlet.doPost(CometdServlet.java:159)
 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:431)
 at org.apache.catalina.core.StandardWrapperValve.preInvoke(StandardWrapperValve.java:462)
 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)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:187)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:142)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:719)
 at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:657)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:651)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1030)
 at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:242)
 at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
 at com.sun.grizzly.http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:633)
 at com.sun.grizzly.http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
 at com.sun.grizzly.http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
 at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
 at com.sun.enterprise.v3.services.impl.GlassfishProtocolChain.executeProtocolFilter(GlassfishProtocolChain.java:71)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:103)
 at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:89)
 at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
 at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
 at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:56)
 at com.sun.grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
 at com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
|#]

我在 domain.xml 中使用以下内容
<http-listener default-virtual-server="server" server-name="" address="0.0.0.0" port="%%%HTTP_PORT%%%" id="http-listener-1">
   <!-- added by akshay -->
   <property name="cometSupport" value="true"/>
   <!-- done -->
  </http-listener>
        <http-listener default-virtual-server="server" enabled="false" security-enabled="true" server-name="" address="0.0.0.0" port="%%%HTTP_SSL_PORT%%%" id="http-listener-2">
          <ssl ssl3-enabled="false" cert-nickname="s1as" />
    <!-- added by akshay -->
   <property name="cometSupport" value="true"/>
   <!-- done -->
        </http-listener>
        <http-listener default-virtual-server="__asadmin" server-name="" address="0.0.0.0" port="%%%ADMIN_PORT%%%" id="admin-listener">
   <!-- added by akshay -->
   <property name="cometSupport" value="true"/>
   <!-- done -->
  </http-listener>

最佳答案

在 Web 管理控制台中启用 Comet 支持

  • 启动 GlassFish Server,导航到 Web 管理控制台(默认:
    localhost:4848/) 在浏览器中。
  • 在左侧的“Common Task”盘中,选择“Configuration” –>
    “网络配置” –> “网络监听器” –> “http-listener-1”
  • 在“编辑网络监听器”中,选择选项卡“HTTP”。
  • 在“HTTP”选项卡下,选中“Comet Support”复选框
  • 单击“保存”按钮(在框架顶部)

  • 完毕!

    关于java - 在 glassfish 服务器中启用 Comet,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4063359/

    10-11 00:18