You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sri Sankaran <Sr...@sas.com> on 2002/08/26 17:53:34 UTC

Hesitation leads to NullPointerException

Using Struts 1.0.2 on Tomcat 4.0.2

<bizarre.alert>

I have a problem that only occurs if the user lingers on a page for a while (say a few minutes).  If after this duration, the user triggers any action, the application crashes with a NullPointerException.

I have debugged the exception as being caused by a null property of the form bean.   The question is this: how did the list get to be null.  Why does it become null only if the user lingers?

The form bean (ProductsListBean) contains :

  private ArrayList products;
  public List getProducts() { return products; }

This list is used to display a collection of products for the user to select (so, I know that the list is non-null & non-empty).  In the processing of the user action, the following logic can be found

  ...
  List products = productsListBean.getProducts();
  Iterator iterator = products.iterator();
  ...

Obviously, (since the list is null) the application throws the exception at the second line above.  

</bizarre.alert>

Since the stack trace on the browser didn't indicate the "Root Cause" I went looking for the Tomcat log -- it said the same thing that was on the browser.  No more information. 

BTW my session timeout is set to 30 minutes and the this problem presents itself if the user pauses for 2-3 minutes.


Sri