org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: STREAM

Spring JIRA | Andreas Kluth | 2 years ago
  1. 0

    When the following code snippet is executed on Tomcat 7.0.59/8.0.20 or Jetty 9.2.9 instead of an error page either nothing (Tomcat) or a "Service Unavailable" (Jetty) page is displayed. Instead of the above behaviour the default (Spring Boot) white-label error page should be handling the faulty request, however fails at: {{org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.SpelView.render(Map<String, ?>, HttpServletRequest, HttpServletResponse)}} I observed a similar issue: https://github.com/spring-projects/spring-boot/issues/1920 which was fixed in tomcat; however this scenario seems to be Spring Web MVC specific. h3. Sample Source {code} @Controller @EnableAutoConfiguration public class Application { @RequestMapping("/") @ResponseBody DeferredResult<String> home() { DeferredResult<String> result = new DeferredResult<>(2000); ForkJoinPool.commonPool().execute(() -> { doHeavyWork(result); }); return result; } private void doHeavyWork(DeferredResult<String> result) { try { Thread.sleep(3000); } catch (InterruptedException e) { Thread.interrupted(); } result.setResult("Hello World"); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } {code} h3. Stacktrace Jetty: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: STREAM at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handleAsync(Server.java:553) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347) at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:261) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalStateException: STREAM at org.eclipse.jetty.server.Response.getWriter(Response.java:920) at org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView.render(ErrorMvcAutoConfiguration.java:196) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) ... 21 common frames omitted {code} h3. Tomcat 8.0.20 {code} java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:328) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318) at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:439) at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:305) at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399) at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:434) at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:289) at org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1705) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:650) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) {code}

    Spring JIRA | 2 years ago | Andreas Kluth
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: STREAM
  2. 0

    When the following code snippet is executed on Tomcat 7.0.59/8.0.20 or Jetty 9.2.9 instead of an error page either nothing (Tomcat) or a "Service Unavailable" (Jetty) page is displayed. Instead of the above behaviour the default (Spring Boot) white-label error page should be handling the faulty request, however fails at: {{org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration.SpelView.render(Map<String, ?>, HttpServletRequest, HttpServletResponse)}} I observed a similar issue: https://github.com/spring-projects/spring-boot/issues/1920 which was fixed in tomcat; however this scenario seems to be Spring Web MVC specific. h3. Sample Source {code} @Controller @EnableAutoConfiguration public class Application { @RequestMapping("/") @ResponseBody DeferredResult<String> home() { DeferredResult<String> result = new DeferredResult<>(2000); ForkJoinPool.commonPool().execute(() -> { doHeavyWork(result); }); return result; } private void doHeavyWork(DeferredResult<String> result) { try { Thread.sleep(3000); } catch (InterruptedException e) { Thread.interrupted(); } result.setResult("Hello World"); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } {code} h3. Stacktrace Jetty: {code} org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: STREAM at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handleAsync(Server.java:553) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347) at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:261) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.IllegalStateException: STREAM at org.eclipse.jetty.server.Response.getWriter(Response.java:920) at org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView.render(ErrorMvcAutoConfiguration.java:196) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) ... 21 common frames omitted {code} h3. Tomcat 8.0.20 {code} java.lang.IllegalStateException: Cannot forward after response has been committed at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:328) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318) at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:439) at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:305) at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:399) at org.apache.catalina.core.AsyncContextImpl.setErrorState(AsyncContextImpl.java:434) at org.apache.catalina.connector.CoyoteAdapter.asyncDispatch(CoyoteAdapter.java:289) at org.apache.coyote.http11.AbstractHttp11Processor.asyncDispatch(AbstractHttp11Processor.java:1705) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:650) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) {code}

    Spring JIRA | 2 years ago | Andreas Kluth
    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: STREAM
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    long-polling cuases IllegalStateException: "STREAM"

    Google Groups | 2 years ago | Randy Ficker
    java.lang.IllegalStateException: STREAM
  5. 0

    IllegalStateException while accepting a client connection

    Eclipse Bugzilla | 2 years ago | sinha.k
    java.lang.IllegalStateException: STREAM

  1. kid 4 times, last 8 months ago
4 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    STREAM

    at org.eclipse.jetty.server.Response.getWriter()
  2. Jetty
    Response.getWriter
    1. org.eclipse.jetty.server.Response.getWriter(Response.java:920)
    1 frame
  3. Spring Boot AutoConfigure
    ErrorMvcAutoConfiguration$SpelView.render
    1. org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView.render(ErrorMvcAutoConfiguration.java:196)
    1 frame
  4. Spring MVC
    FrameworkServlet.doGet
    1. org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1228)
    2. org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1011)
    3. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:955)
    4. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877)
    5. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
    6. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
    6 frames
  5. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    1 frame
  6. Spring MVC
    FrameworkServlet.service
    1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
    1 frame
  7. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
    1 frame
  8. Jetty
    QueuedThreadPool$3.run
    1. org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808)
    2. org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
    3. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
    4. org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:595)
    5. org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
    6. org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
    7. org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    8. org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    9. org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
    10. org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    11. org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    12. org.eclipse.jetty.server.Server.handleAsync(Server.java:553)
    13. org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)
    14. org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:261)
    15. org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
    16. org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
    16 frames
  9. Java RT
    Thread.run
    1. java.lang.Thread.run(Unknown Source)
    1 frame