I am using grizzly with jersey, with the configuration being built in code.
GrizzlyWebServer ws = new GrizzlyWebServer(8000, ".", USE_SSL);
ServletAdapter sa = new ServletAdapter();
sa.setServletInstance(new ServletContainer());
sa.addServletListener(ProtobufServletConfig.class.getName());
sa.addFilter(new GuiceFilter(), "guiceFilter", null);
ws.addGrizzlyAdapter(sa, new String[]{"/"});
I notice I can POST to it something up to about 64000 bytes, after
that it blows up with a series of terrible exceptions. I think I need
to set max-post-size (or call setMaxPostSize()) but I'm not sure
where, couldn't find answer in mailing list archives. How do I set
this? And am I right that it's probably the problem?
It shows a stack exception due to infinite recursion. Eventually I see
ERROR com.sun.grizzly.http.ProcessorTask (686) Error finishing request
java.lang.IllegalStateException: Only one available listener allowed!
and it gives up.
ERROR com.sun.grizzly.http.servlet.ServletAdapter (278) service exception:
javax.servlet.ServletException: Throwable
at com.sun.grizzly.http.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:180)
at com.sun.grizzly.http.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:137)
at com.sun.grizzly.http.servlet.ServletAdapter.service(ServletAdapter.java:276)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:165)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:722)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:606)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:890)
at com.sun.grizzly.http.WebFilter.handleRead(WebFilter.java:220)
at com.sun.grizzly.arp.AsyncWebFilter.handleRead(AsyncWebFilter.java:95)
at com.sun.grizzly.filterchain.DefaultFilterChain$3.execute(DefaultFilterChain.java:89)
at com.sun.grizzly.filterchain.DefaultFilterChain.executeChain(DefaultFilterChain.java:244)
at com.sun.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:179)
at com.sun.grizzly.filterchain.AbstractFilterChain.process(AbstractFilterChain.java:148)
at com.sun.grizzly.ProcessorRunnable.run(ProcessorRunnable.java:232)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.StackOverflowError
at sun.security.ssl.ProtocolVersion.valueOf(ProtocolVersion.java:101)
at sun.security.ssl.ProtocolVersion.valueOf(ProtocolVersion.java:124)
at sun.security.ssl.EngineInputRecord.bytesInCompletePacket(EngineInputRecord.java:108)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:784)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:697)
at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
at com.sun.grizzly.ssl.SSLStreamReader.appendBuffer(SSLStreamReader.java:102)
at com.sun.grizzly.streams.StreamReaderDecorator$FeederCompletionHandler.completed(StreamReaderDecorator.java:176)
at com.sun.grizzly.nio.transport.TCPNIOStreamReader.notifyCondition(TCPNIOStreamReader.java:87)
at com.sun.grizzly.streams.AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:580)
at com.sun.grizzly.streams.StreamReaderDecorator$FeederCompletionHandler.completed(StreamReaderDecorator.java:181)
at com.sun.grizzly.nio.transport.TCPNIOStreamReader.notifyCondition(TCPNIOStreamReader.java:87)
at com.sun.grizzly.streams.AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:580)
at com.sun.grizzly.streams.StreamReaderDecorator$FeederCompletionHandler.completed(StreamReaderDecorator.java:181)
at com.sun.grizzly.nio.transport.TCPNIOStreamReader.notifyCondition(TCPNIOStreamReader.java:87)
at com.sun.grizzly.streams.AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:580)
at com.sun.grizzly.streams.StreamReaderDecorator$FeederCompletionHandler.completed(StreamReaderDecorator.java:181)
at com.sun.grizzly.nio.transport.TCPNIOStreamReader.notifyCondition(TCPNIOStreamReader.java:87)
--- STARTING HERE, THIS REPEATS FOREVER, it really does look like
infinite recursion.
--- When it finally gives up looping this message:
ERROR com.sun.grizzly.http.ProcessorTask (686) Error finishing request
java.lang.IllegalStateException: Only one available listener allowed!
at com.sun.grizzly.streams.StreamReaderDecorator.notifyCondition(StreamReaderDecorator.java:100)
at com.sun.grizzly.streams.AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:580)
at com.sun.grizzly.streams.AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:572)
at com.sun.grizzly.tcp.http11.InternalInputBuffer.fill(InternalInputBuffer.java:783)
at com.sun.grizzly.tcp.http11.InternalInputBuffer$InputStreamInputBuffer.doRead(InternalInputBuffer.java:819)
at com.sun.grizzly.tcp.http11.filters.IdentityInputFilter.end(IdentityInputFilter.java:198)
at com.sun.grizzly.tcp.http11.InternalInputBuffer.endRequest(InternalInputBuffer.java:363)
at com.sun.grizzly.http.ProcessorTask.postResponse(ProcessorTask.java:682)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:607)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:890)
at com.sun.grizzly.http.WebFilter.handleRead(WebFilter.java:220)
at com.sun.grizzly.arp.AsyncWebFilter.handleRead(AsyncWebFilter.java:95)
at com.sun.grizzly.filterchain.DefaultFilterChain$3.execute(DefaultFilterChain.java:89)
at com.sun.grizzly.filterchain.DefaultFilterChain.executeChain(DefaultFilterChain.java:244)
at com.sun.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:179)
at com.sun.grizzly.filterchain.AbstractFilterChain.process(AbstractFilterChain.java:148)
at com.sun.grizzly.ProcessorRunnable.run(ProcessorRunnable.java:232)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:636)