It's not a secret anymore!
The moose likes Servlets and the fly likes weird non-deterministic problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "weird non-deterministic problem" Watch "weird non-deterministic problem" New topic

weird non-deterministic problem

Mirko Froehlich
Ranch Hand

Joined: Aug 21, 2000
Posts: 114
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.
BTW: We are using Netscape Enterprise Server and Bluestone Sapphire UBS as the application server.
Any ideas???
I agree. Here's the link:
subject: weird non-deterministic problem
It's not a secret anymore!