I am new to Spring and I can't find out why my controller raises a null pointer exception.
My controller's code
My serviceCode:@Controller @RequestMapping("/home") public class HomeController { @RequestMapping(method = RequestMethod.GET) protected ModelAndView handleRequestInterval( HttpServletRequest request, HttpServletResponse response) throws Exception{ List<String> recentRants = rantService.getRecentRants(); //this fails return new ModelAndView("home","rants",recentRants); } private RantService rantService; public void setRantService(RantService rantService) { this.rantService = rantService; } }
My service-conf.xmlCode:@Service public class RantService { @Autowired public List<String> getRecentRants(){ List<String> l = new ArrayList<String>(); l.add("one"); l.add("two"); return l; } }
<context:component-scan base-package="net.nacho.services" />
that points to the package where my Service is placed
I was looking for similar problems-solutions but no luck. Anyone could give me a clue?


Reply With Quote
You are you annotating the getRecentRants method with @Autowired?

