Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Login problem "Request processing failed; nested exception is java.lang.NullPointerException"

 
Deepaks Deshpande
Ranch Hand
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Deepaks Deshpande
Ranch Hand
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your JSP also
 
Deepaks Deshpande
Ranch Hand
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my login page code:
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 114
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. Its working now.
 
Prasad Krishnegowda
Ranch Hand
Posts: 671
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepaks Deshpande wrote:Thank you very much. Its working now.


Glad to hear, its working..
You are Welcome Brother..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic