I dont know what is wrong in my listContacts
in controller
map.put(\"contactList\", contactService.listContact());
Can somebody help me?
I think you are missing to add the contactService bean to your applicationContext.xml try adding the below to tags
<bean id="contactService" class="pl.ivmx.contact.service.ContactServiceImpl">
<property name="contactDAO" ref="contactDAO" />
</bean>
<bean id="contactDAO" class="pl.ivmx.contact.dao.ContactDAOImpl" />
It looks like a NullPointerException thrown in the method here:
@RequestMapping("/contact")
public String listContacts(Map<String, Object> map) {
map.put("contact", new Contact());
map.put("contactList", contactService.listContact());
return "/contact";
}
I would debug and check that contactService has been autowired correctly.
The null pointer is line 26, if that is the line containing contactService.listContact()
then contactService is null. If it is the line above then the map
is null.
I am not sure but try adding:
<context:component-scan base-package="pl.ivmx.contact" />
to the dispatcher-servlet.xml as well, it could be that the annotation isnt getting processed
I don't see anything obvious ... could sessionFactory be null? Should be easy to find, tho. Step through the code in the debugger.
you are returning "/contact"
there in the method as a view to be shown:
@RequestMapping("/contact")
public String listContacts(Map<String, Object> map) {
map.put("contact", new Contact());
map.put("contactList", contactService.listContact());
return "/contact"; // <---- here!
}
This means that you should have a view named /contact defined somewhere, but I don't see it. You need to have a view that corresponds with the value you're defining.
You probably want to return a value like "contact"
instead of "/contact"
and then have contact.jsp in the webapp/WEB-INF/views folder (assuming you use maven standard directory layout).