| Author |
Spring Login problem "Request processing failed; nested exception is java.lang.NullPointerException"
|
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Dear Ranchers,
I am creating a login application using spring mvc and ibatis. But i am getting a NPE and i am not able to solve this issue from the past 2 days . Please help me.
My Form controller is
My spring application context file is:
My ibatis configuration file is:
and my SqlMapConfig file is:
My console prints the following and i can make out the username is null so i am getting this NPE. But why does it print the password that the user entered and not the username? Can anybody please explain where i am going wrong?
Please help me as i am stuck here and i don't have any idea as to why i am getting this error.Thank you
|
Regards,
Deepak
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
In your posted code, line 57 is blank, but the NPE occurs on line 57, can you post that line of code?
EDIT: Can you also post your command class and JSP file?
P:S: Still extending SimpleFormController in the spring3 era? I would suggest you to use annotations instead, which makes is more powerful and simpler.
|
Regards, Prasad
SCJP 5 (93%)
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
|
This project requires spring 2x as it has been developed using spring 2x. So please guide me to solve this problem. Thank you
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
My command class is
The line 57 in LoginFormController class is
This is the message printed out on to the console
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
|
Please post your JSP also
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
This is my login page code:
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
change this line <input type="text" name="name" id="name" />
to <input type="text" name="userId" id="userId" /> and you should get the user entered id, in the controlller, for spring to bind them, you should have same name in both command class as well as JSP.
EDIT: either you can do the above change, or have objUserLogin.getName in your controller instead of objUserLogin.getUserId() on line 57.
|
 |
Deepaks Deshpande
Ranch Hand
Joined: Dec 06, 2007
Posts: 95
|
|
Thank you very much. Its working now.
|
 |
Prasad Krishnegowda
Ranch Hand
Joined: Apr 25, 2010
Posts: 503
|
|
Deepaks Deshpande wrote:Thank you very much. Its working now.
Glad to hear, its working..
You are Welcome Brother..
|
 |
 |
|
|
subject: Spring Login problem "Request processing failed; nested exception is java.lang.NullPointerException"
|
|
|