title: Spring boot web application throws getOutputStream() has already been called for this response
body: <p>I have spring boot web application built using spring boot 1.4.0.RELEASE and embedded tomcat version is 8.5.4. I am seeing the "IllegalStateException due to getOoputStream() has already called" exception occasionally in my log. I don't know exactly when it comes.</p>
  
  <p>The spring boot webapp built using jsp, tiles and mvc rest controller. The rest controller is very simple and it doesn't use responsestream. Here is my error log,</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response
      at org.apache.catalina.connector.Response.getWriter(Response.java:609) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:211) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:109) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:118) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:111) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:176) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:120) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:75) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) ~[tomcat-embed-jasper-8.5.4.jar!/:8.5.4]
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:186) ~[spring-security-web-3.2.3.RELEASE.jar!/:3.2.3.RELEASE]
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) ~[spring-security-web-3.2.3.RELEASE.jar!/:3.2.3.RELEASE]
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:101) ~[spring-web-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:592) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:526) ~[tomcat-embed-core-8.5.4.jar!/:8.5.4]
      at org.apache.tiles.request.servlet.ServletRequest.doInclude(ServletRequest.java:243) ~[tiles-request-servlet-1.0.0.jar!/:1.0.0]
      at org.apache.tiles.request.servlet.ServletRequest.doForward(ServletRequest.java:226) ~[tiles-request-servlet-1.0.0.jar!/:1.0.0]
      at org.apache.tiles.request.AbstractClientRequest.dispatch(AbstractClientRequest.java:57) ~[tiles-request-api-1.0.0.jar!/:1.0.0]
      at org.apache.tiles.request.render.DispatchRenderer.render(DispatchRenderer.java:45) ~[tiles-request-api-1.0.0.jar!/:1.0.0]
      at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:259) ~[tiles-core-3.0.0.jar!/:3.0.0]
      at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:397) ~[tiles-core-3.0.0.jar!/:3.0.0]
      at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:238) ~[tiles-core-3.0.0.jar!/:3.0.0]
      at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:221) ~[tiles-core-3.0.0.jar!/:3.0.0]
      at org.apache.tiles.renderer.DefinitionRenderer.render(DefinitionRenderer.java:59) ~[tiles-core-3.0.0.jar!/:3.0.0]
      at org.springframework.web.servlet.view.tiles3.TilesView.renderMergedOutputModel(TilesView.java:132) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
      ... 25 more
  
  
  
  
  
  
  
  
     @Controller
      @RequestMapping("/")
      public class MainController{        
          @RequestMapping(value = {"/list"}, method = RequestMethod.GET)
          public String blacklist(ModelMap model) {
              //processing
              return "list";
          }
  
          @RequestMapping(value = {"/Find"}, method = RequestMethod.POST)
          public String find(ModelMap model, @ModelAttribute("attribute1")String attr) {
              //processing
              return "list";
          }
      }
  </code></pre>