This is my Web.xml
file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>loungeHotel</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/loungeHotel.xml
</param-value>
</context-param>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
This is my loungeHotel.xml
file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<bean id = "updateProfileDao" class="com.lounge.dao.impl.UpdateProfileDaoImpl"></bean>
<bean id = "updateProfileFacade" class="com.lounge.facades.impl.UserProfileFacadeImpl">
<property name="updateProfileDao" ref="updateProfileDao"></property>
</bean>
</beans>
this is the java file(UserProfileFacadeImpl.java
) where i want to use my bean (updateProfileDao
)
package com.lounge.facades.impl;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Required;
import com.lounge.dao.impl.UpdateProfileDaoImpl;
import com.lounge.dataModels.StudentData;
import com.lounge.facade.UserProfileFacade;
public class UserProfileFacadeImpl implements UserProfileFacade {
@Resource(name="updateProfileDao")
private UpdateProfileDaoImpl updateProfileDao;
public UpdateProfileDaoImpl getUpdateProfileDao() {
return updateProfileDao;
}
@Required
public void setUpdateProfileDao(UpdateProfileDaoImpl updateProfileDao) {
this.updateProfileDao = updateProfileDao;
}
@Override
public StudentData updateProfile(StudentData studentData,String name){
return getUpdateProfileDao().updateColumn(studentData, name);
}
}
here is stacktrace...
>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)
javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
>java.lang.**NullPointerException**
com.lounge.facades.impl.UserProfileFacadeImpl.updateProfile(UserProfileFacadeImpl.java:30)
com.lounge.controllers.AccountPageController.updateProfile(AccountPageController.java:63)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)