How about the NullPointerException in HttpGenerator?
By the way, I hacked the HttpGenerator and AbstractGenerator to synchronize
access to the _content buffer. While this solves the NPE and makes the SSE
flow like they should, each time a SSE request is made from a browser, a
Jetty thread ends up in an infinite loop in BlockingHttpConnection.handle():
"qtp1133736492-19" prio=5 tid=7fe871853800 nid=0x10b57f000 runnable
[10b57e000]
java.lang.Thread.State: RUNNABLE
at
org.eclipse.jetty.http.HttpGenerator.prepareBuffers(HttpGenerator.java:943)
- locked <7f45cb7a8> (a java.lang.Object)
at
org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:822)
- locked <7f45cb7a8> (a java.lang.Object)
at
org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:79)
at
org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at
org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:680)
I have a strong feeling that the SocketConnector was never tested with
async servlets, and I even fear that its internal design prevents it from
ever supporting them.
Since some of my code extends the SocketConnector and cannot use the
SelectChannelConnector, does that mean I'll never manage to get SSE working
in that setup?
Thanks,
Ludovic
On Mon, Jun 2, 2014 at 4:35 PM, Joakim Erdfelt <[email protected]> wrote:
> an EofException during HttpOutput.write() normally means that the
> connection was terminated before it had a chance to finish writing the
> entire response.
> A *very* common occurrence in the wild.
>
> --
> Joakim Erdfelt <[email protected]>
> webtide.com <http://www.webtide.com/> - intalio.com/jetty
> Expert advice, services and support from from the Jetty & CometD experts
> eclipse.org/jetty - cometd.org
>
>
> On Fri, May 30, 2014 at 1:16 PM, Ludovic Orban <[email protected]> wrote:
>
>> Hi,
>>
>> I've tried using Jersey Server Sent Events with jetty 8.15 and everything
>> seems to work quite nicely... as long as I use the SelectChannelConnector.
>> If I use the SocketConnector, I get this kind of error logged on the
>> console and the SSE client gets an error:
>>
>> 2014-05-30 22:02:40.736:WARN:oejsb.SocketConnector:handle failed?
>> java.lang.NullPointerException
>> at
>> org.eclipse.jetty.http.HttpGenerator.prepareBuffers(HttpGenerator.java:933)
>> at
>> org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:811)
>> at
>> org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:79)
>> at
>> org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
>> at
>> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
>> at java.lang.Thread.run(Thread.java:680)
>> Exception in thread "Thread-13" java.lang.RuntimeException: Error when
>> writing the event.
>> at
>> sample.jersey.HelloResourceService$1.run(HelloResourceService.java:53)
>> at java.lang.Thread.run(Thread.java:680)
>> Caused by: org.eclipse.jetty.io.EofException
>> at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:142)
>> at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:117)
>> at
>> org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:214)
>> at
>> org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:237)
>> at
>> org.glassfish.jersey.server.ChunkedOutput$1.call(ChunkedOutput.java:192)
>> at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
>> at org.glassfish.jersey.internal.Errors.process(Errors.java:242)
>> at
>> org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:346)
>> at
>> org.glassfish.jersey.server.ChunkedOutput.flushQueue(ChunkedOutput.java:192)
>> at
>> org.glassfish.jersey.server.ChunkedOutput.write(ChunkedOutput.java:182)
>> at
>> sample.jersey.HelloResourceService$1.run(HelloResourceService.java:50)
>> ... 1 more
>>
>> Here's a simple maven project that reproduces the problem:
>>
>> https://dl.dropboxusercontent.com/u/3512020/jetty/jetty-async.zip
>>
>> It contains a simple Main class that starts a sample webap on top of a
>> server configured with both connectors, the NIO one listening on 9999 and
>> the BIO one on 8888. When I hit http://localhost:9999/hello/ I see the
>> events appearing, but when I try http://localhost:8888/hello/ fails.
>>
>> Could there be a bug in the BIO connector?
>>
>> Thanks,
>> Ludovic
>>
>> _______________________________________________
>> jetty-users mailing list
>> [email protected]
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>>
>>
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users