title: java.lang.StackOverflowError with Spring Boot Actuator & Tomcat
body: <p>I have a spring-boot application with spring-boot-starter-actuator enabled.
  If I deploy the war file into a tomcat container, I get a stack overflow when I hit unmapped uri.</p>
  
  <pre><code>2014-06-03 17:24:28,312 WARN  [http-bio-8080-exec-3]             o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/catalog/products] in DispatcherServlet with name 'dispatcherServlet'
      Exception in thread "http-bio-8080-exec-3" java.lang.StackOverflowError
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.apache.catalina.core.ApplicationHttpRequest.setAttribute(ApplicationHttpRequest.java:281)
  at org.springframework.boot.context.web.ErrorPageFilter.setErrorAttributes(ErrorPageFilter.java:164)
  at org.springframework.boot.context.web.ErrorPageFilter.handleException(ErrorPageFilter.java:131)
  at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:104)
  at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:85)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
  at org.springframework.boot.context.web.ErrorPageFilter.handleException(ErrorPageFilter.java:135)
  at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:104)
  at org.springframework.boot.context.web.ErrorPageFilter.doFilter(ErrorPageFilter.java:85)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
  at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:749)
  at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:487)
  at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:412)
  at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:339)
  </code></pre>
  
  <p>I tried implementing the ErrorController, but it did not work. Did anyone see similar issue? What could be causing this?</p>
  
  <p>But if I run using the embedded tomcat server, everything looks good with the white label error page displayed. For various operational reasons, I need to run the app inside a tomcat container. Any help is highly appreciated.</p>
  
  <p><strong>Update:</strong>
  I narrowed it down to a filter that wraps servlet request &amp; response. I am at a loss to explain why it has issues when both this filter and actuator are included in a tomcat container. It works fine when either one of them is not included. I have created a sample app with just enough code to replicate it here in a <a href="https://github.com/vgadang/spring-actuator-stack-overflow" rel="nofollow">Sample Code</a></p>