项目中需要实现Comet push机制,采用jetty7+dwr2.06。当页面刷新时,经常会出现异常信息,但异常并不妨碍功能的实现,照样可以push数据,不过出现异常总感到不爽,不知道是否有人遇到过,有没有可以避免的方法。 下面异常信息:
2010-5-11 22:43:38 org.directwebremoting.util.CommonsLoggingOutput warn
警告: Unhandled Exception
org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:223)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:235)
at org.eclipse.jetty.io.UncheckedPrintWriter.print(UncheckedPrintWriter.java:384)
at org.eclipse.jetty.io.UncheckedPrintWriter.println(UncheckedPrintWriter.java:542)
at org.directwebremoting.dwrp.PlainScriptConduit.addScript(PlainScriptConduit.java:86)
at org.directwebremoting.extend.EnginePrivate.remoteHandleException(EnginePrivate.java:118)
at org.directwebremoting.dwrp.BaseScriptConduit.close(BaseScriptConduit.java:111)
at org.directwebremoting.dwrp.PollHandler$1.run(PollHandler.java:199)
at org.directwebremoting.dwrp.ThreadWaitSleeper.goToSleep(ThreadWaitSleeper.java:45)
at org.directwebremoting.dwrp.PollHandler.handle(PollHandler.java:211)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:427)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:457)
at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:334)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1007)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:747)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:885)
at org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:486)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:145)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:86)
at java.io.ByteArrayOutputStream.writeTo(Unknown Source)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:258)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:107)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:214)
... 34 more
Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at sun.nio.ch.SocketDispatcher.writev0(Native Method)
at sun.nio.ch.SocketDispatcher.writev(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write0(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at java.nio.channels.SocketChannel.write(Unknown Source)
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:237)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:221)
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:818)
... 41 more
2010-05-11 22:43:38.463:WARN::Committed before 501 Error. Details logged to the console
个人觉得:每次请求,浏览器端都会创建一个与服务器的长连接,jetty必须关闭先前的长连接;当刷新时,服务器端只能保存一个该请求的长连接,即用新创建的去取代先前已经存在的长连接,服务器端会强制关闭先前的连接,此时dwr或jetty封装的时候,异常没处理好,应该是其本身的bug。不知大家有什么看法,本人也是初次使用。
2010-5-11 22:43:38 org.directwebremoting.util.CommonsLoggingOutput warn
警告: Unhandled Exception
org.eclipse.jetty.io.RuntimeIOException: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:223)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:235)
at org.eclipse.jetty.io.UncheckedPrintWriter.print(UncheckedPrintWriter.java:384)
at org.eclipse.jetty.io.UncheckedPrintWriter.println(UncheckedPrintWriter.java:542)
at org.directwebremoting.dwrp.PlainScriptConduit.addScript(PlainScriptConduit.java:86)
at org.directwebremoting.extend.EnginePrivate.remoteHandleException(EnginePrivate.java:118)
at org.directwebremoting.dwrp.BaseScriptConduit.close(BaseScriptConduit.java:111)
at org.directwebremoting.dwrp.PollHandler$1.run(PollHandler.java:199)
at org.directwebremoting.dwrp.ThreadWaitSleeper.goToSleep(ThreadWaitSleeper.java:45)
at org.directwebremoting.dwrp.PollHandler.handle(PollHandler.java:211)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:146)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:427)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:457)
at org.eclipse.jetty.server.session.SessionHandler.handle(SessionHandler.java:182)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:933)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:362)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
at org.eclipse.jetty.server.Server.handle(Server.java:334)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:559)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1007)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:747)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:203)
at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:406)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:462)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
at java.lang.Thread.run(Unknown Source)
Caused by: org.eclipse.jetty.io.EofException
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:885)
at org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:486)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:145)
at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:86)
at java.io.ByteArrayOutputStream.writeTo(Unknown Source)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:258)
at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:107)
at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:214)
... 34 more
Caused by: java.io.IOException: 远程主机强迫关闭了一个现有的连接。
at sun.nio.ch.SocketDispatcher.writev0(Native Method)
at sun.nio.ch.SocketDispatcher.writev(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write0(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at java.nio.channels.SocketChannel.write(Unknown Source)
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:237)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:221)
at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:818)
... 41 more
2010-05-11 22:43:38.463:WARN::Committed before 501 Error. Details logged to the console
个人觉得:每次请求,浏览器端都会创建一个与服务器的长连接,jetty必须关闭先前的长连接;当刷新时,服务器端只能保存一个该请求的长连接,即用新创建的去取代先前已经存在的长连接,服务器端会强制关闭先前的连接,此时dwr或jetty封装的时候,异常没处理好,应该是其本身的bug。不知大家有什么看法,本人也是初次使用。