Hey Everyone,
This one has me really stumped. I'm developing a web app for tomcat 6 and using struts2. I have an action that gets some variables from the ActionContext.
The strange thing is that the variables, sometimes, don't get set the first time I try to assign them. The code looks like this...
results = (List) ActionContext.getContext().getSession().get("RESULTS");
properties = (DisplayProperty[]) ActionContext.getContext().getSession().get("PROPERTIES");
On occasion I would get a null pointer exception and after a few hours of tracking I found that these assignments are not working, almost like they're being ignored.
I added this after the above code since I found that everything is in the session properly..
while(properties == null){
System.out.println("Properties null in Result Action!");
properties = (DisplayProperty[]) ActionContext.getContext().getSession().get("PROPERTIES");
results = (List) ActionContext.getContext().getSession().get("RESULTS");
}
And typically in 1 iteration this resolves the problem.
Can anyone shine some light on why the first assignment wouldn't work 100% of the time. It fails anywhere between the 3rd and 30th call. (really really rough estimate of fail rate... can't find a specific instance that causes it)
Thanks!