text: weird non-deterministic problem (Servlets forum at Coderanch)
  We have discovered a very weird, non-deterministic problem in a JSP page. The page is fairly simple, it mainly uses one JavaBean that gets some data from an Oracle database. The bean is instantiated with a usebean tag, and then a couple of setters and other methods are executed on it. When I run it on my personal machine, everything works fine. However, on the Unix QA and production servers, the bean behaves very weird. The JSP pages uses the following code to iterate over some data:
  String currentHeader = "";
  for (int i = 2; i <= comp.getNumCols(); i++) {
  currentHeader = comp.getHeader(i);
  // do stuff with the header
  Don't ask why we are iterating from index 2 to the number of columns, but this is correct. For some reason, if we print out the value of "i" in getHeader, it prints out some very large negative integer, instead of the numbers 2 through the number of columns (typically < 10). This in turn causes an ArrayIndexOutOfBoundsException in the bean. This should never be able to happen. We added some debug output to dump the value of "i" in the loop on the JSP page, and it outputs the correct values. The weird thing is that this also FIXES THE PROBLEM! Consequently, removing this debug output re-introduces the problem again.
  This reminds me very much of a problem I had in a C++ program a few years ago, which was caused by some kind of memory corruption. As in our case, adding debug output sometimes fixed the problem... However, as far as I know, something like this should never be able to happen in Java. The only thing that might happen in Java if objects are not correctly garbage collected is a memory leak, but that is not the case. This happens even after restarting the application server, no matter if this is the first page that gets hit or if we wait a while.