This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 203

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: 203
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
problem in uploading the file in springframework
que in spring mvc - simpleformcontroller
org.springframework.web.servlet.DispatcherServlet noHandlerFound
Not able to Validate form using JSR-303 validation implementation in Spring MVC
issues in calling the ejbcontroller (EJB 3.o ) from the controller using spring Frame