aspose file tools*
The moose likes Struts and the fly likes validate() method throwing a NullPointerException with execAndWait interceptor. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "validate() method throwing a NullPointerException with execAndWait interceptor." Watch "validate() method throwing a NullPointerException with execAndWait interceptor." New topic
Author

validate() method throwing a NullPointerException with execAndWait interceptor.

Abhimanyus singh
Greenhorn

Joined: Apr 11, 2012
Posts: 27
Hi Guys.....
I've a problem ...
I'm trying to implement execAndWait interceptor...just to give an impression to the user that some heavy task starts executing..as sooon as he.she logs in....but...after displaying the default wait page for a certain period of time, the web page informs that a NPE is thrown...

my struts.xml is:::-->

The Exception's stack trace is as follows:::



The Action Class is:::


The line 32 of my Action Class is trying to test whether the user has entered his/her name or not !!


Please help !!!
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi,

Try to get the value for username while debugging , i think this.username is null and when you try to invoke method isempty on null it gives you the exception.

Regards
Jatan
Abhimanyus singh
Greenhorn

Joined: Apr 11, 2012
Posts: 27
jatan bhavsar wrote:Hi,

Try to get the value for username while debugging , i think this.username is null and when you try to invoke method isempty on null it gives you the exception.

Regards
Jatan


Yeah...That seems to be the issue...but, please let me know , on how to get rid of it !!!
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Check to see if your field "username" is exactly the same as the one received from your form JSP . Check for spelling mistakes . Also verify that you are using the correct case . Keep care , since UserName is not the same as username .


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Abhimanyus singh
Greenhorn

Joined: Apr 11, 2012
Posts: 27
Saif Asif wrote:Check to see if your field "username" is exactly the same as the one received from your form JSP . Check for spelling mistakes . Also verify that you are using the correct case . Keep care , since UserName is not the same as username .


Hi Asif...the field names in the jsp's properly correspond to the properties in the Action Class, as mentioned in the first post, the issue arises only when i put an execAndWait interceptor reference in struts.xml.......and the moment I remove the interceptor reference, everything goes fine, I think the inclusion of the execAndWait interceptor is "kind of" keeps on preventing the mapping of form fields to the respective properties in the Action Class.....but if that is the problem...How can I cure it ??
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8908
    
    8

Why don't you have a "wait" result configured for your action?
I see the documentation says the following:
Important: Because the action will be running in a seperate thread, you can't use ActionContext because it is a ThreadLocal. This means if you need to access, for example, session data, you need to implement SessionAware rather than calling ActionContext.getSession().

ExecuteAndWaitInterceptor
I wonder if you are having a thread-related problem with your validation.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: validate() method throwing a NullPointerException with execAndWait interceptor.