title: UncaughtExceptionHandler in tomcat
body: <p>I'm getting OutOfMemoryError in tomcat source while executing my web application.</p>
  
  <p><strong>java.lang.OutOfMemoryError: Java heap space</strong></p>
  
  <pre><code>java.lang.OutOfMemoryError: Java heap space
  at java.util.Arrays.copyOf(Unknown Source)
  at java.lang.AbstractStringBuilder.expandCapacity(Unknown Source)
  at java.lang.AbstractStringBuilder.append(Unknown Source)
  at java.lang.StringBuilder.append(Unknown Source)
  at com.source.server.wc.common.SupportAction.execute(SupportAction.java:252)
  at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
  at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
  at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
  at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at com.source.server.wc.common.AuthenticationFilter.doFilter(AuthenticationFilter.java:300)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at com.source.server.wc.common.EncodingFilter.doFilter(EncodingFilter.java:70)
  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
  at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:568)
  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
  at java.lang.Thread.run(Unknown Source)    
  </code></pre>
  
  <p>I have added 
  <strong>Thread.currentThread().setDefaultUncaughtExceptionHandler(new OOMEHandler());</strong>    in my main Thread, Now I'm getting OOMError while executing task from webclient, but OOMError not catched by the UncaughtExceptionHandler.</p>
  
  <p>How can i catch it?</p>