title: Is there a practice to diagnose thread hung happened in WebSphere?
body: <pre><code>public void doFilter(ServletRequest request, ServletResponse response,
              FilterChain chain) throws IOException, ServletException {
  
          if ((request instanceof HttpServletRequest)
                  &amp;&amp; (response instanceof HttpServletResponse)) {
              HttpServletRequest httpServletRequest = (HttpServletRequest) request;
              HttpServletResponse httpServletResponse = (HttpServletResponse) response;
  
              if (isSessionControlRequiredForThisResource(httpServletRequest)) {
  
                  if (isSessionInvalid(httpServletRequest)) {
  
                      String encodedURL = httpServletRequest.getContextPath() + this.timeoutPage;
  
                      try {
                          httpServletResponse.sendRedirect(encodedURL);
                      } catch (Exception e) {
                          logger.error("[Error happened in filter] : ", e.fillInStackTrace());
                      }
  
                      return;
                  }
              }
  
              if (!httpServletRequest.getRequestURI().startsWith(httpServletRequest.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) {
                  httpServletResponse.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
                  httpServletResponse.setHeader("Pragma", "no-cache");                    
                  httpServletResponse.setDateHeader("Expires", 0);
                  }
              }
              chain.doFilter(request, response);
          }
  </code></pre>
  
  <p>The code shown above sometime could fail during the mission causing following error shown in <code>SystemOut.log</code>.</p>
  
  <blockquote>
    <p>[8/26/13 8:38:39:873 MYT] 0000002c ThreadMonitor W   WSVR0605W: Thread
    "WebContainer : 9" (00000037) has been active for 611221 milliseconds
    and may be hung.  There is/are 7 thread(s) in total in the server that
    may be hung.</p>
  </blockquote>
  
  <p>It wasn't easy to diagnose this error because this will always follow by a very long list of stack trace which is not belong to my application. And usually it could happened few times for a certain period of time (roughly 15 to 20 minutes) but the thread ID could be different.</p>
  
  <p>I'm not able to simulate this in unit testing in UAT server and I wasn't sure what could be the root cause of this problem. It happens occasionally. Is there a pattern to capture this error? Does it happen after some other exception has occurred say DB connection has lost or perhaps some background process was running, say retrieving huge resultset in production server? I'm just trying to understand what circumstances could lead to this problem so that I can avoid this during my coding.</p>