This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Spring and the fly likes DI is not working in my example. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "DI is not working in my example." Watch "DI is not working in my example." New topic
Author

DI is not working in my example.

Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205

Hi, I am working with SPringMVC. I am trying to use DI functionality provided by Spring, but somehow object is getting NULL value. Hence throwing NullPointerException.
My code is as follows:


Controller is as follows:




I am getting null pointer exception because:


Is LoginService Null3:NULL;















PLease tell me where I am wrong and why I am getting null.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
You need to set your property "loginService" on your bean "/login.html"
Rahul Ba
Ranch Hand

Joined: Oct 01, 2008
Posts: 205
Hi Tom, Thanks for looking into this. but I do not get where to set the loginService bean.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Add <property name="loginService" ref="loginService" /> to your /login.html bean. Follow the pattern of your viewResolver bean to add the property.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DI is not working in my example.
 
Similar Threads
que in spring mvc - simpleformcontroller
org.springframework.web.servlet.DispatcherServlet noHandlerFound
issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame
problem in uploading the file in springframework
Not able to Validate form using JSR-303 validation implementation in Spring MVC