I checked many places, but unable to find the error in my configuration. Please help.
faces-config.xml
<managed-bean>
<managed-bean-name>notificationServlet</managed-bean-name>
<managed-bean-class>com.comviva.workflow.ui.notification.NotificationServlet</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>notificationDao</property-name>
<value>#{notificationDaoService}</value>
</managed-property>
</managed-bean>
applicationContext.xml
<bean id="notificationDao" class="com.comviva.workflow.ui.dao.NotificationDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="notificationDaoService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref local="myTransactionManager" />
</property>
<property name="target">
<ref local="notificationDao" />
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_NEVER</prop>
</props>
</property>
</bean>
Java Class
@SessionScoped
@ManagedBean(name = "notificationServlet")
public class NotificationServlet extends HttpServlet
{
private static final long serialVersionUID = -3905661117247475401L;
@ManagedProperty("#{notificationDao}")
NotificationDao notificationDao;
}
I am getting NullPointerException. Please suggest me what I am missing.
Edit:-
2013-08-13 21:22:34,407 INFO (NotificationServlet.java:43) notificationDao :: null
2013-08-13 21:22:34,407 ERROR (NotificationServlet.java:60) Exception ::
java.lang.NullPointerException
at com.comviva.workflow.ui.notification.NotificationServlet.doPost(NotificationServlet.java:44)
at com.comviva.workflow.ui.notification.NotificationServlet.doGet(NotificationServlet.java:67)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Edit :-
I am not so good in these technologies, but as per my knowledge I am using these because-
Spring - To create bean objects in order to prevent multiple objects creation every time class access.
Servlet - I have to implement facebook like "notifications", so I am "clocking (Polling)" in JSP page the servlet URL to check whether any value updated or not.
JSF - I am using it for the creation of UI. I am very new in JSF, so I was not sure how to implement the Spring with it. So I asked whether I am missing something or not.
and I have setter/getter methods in my class. I just didn't show it to save the space. (apology if it confused the assumptions.)
Solution :-
I removed both beans within faces-config.xml and JSF annoations from Java class. I am catching the dao bean in java class itself by use of :-
WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
notificationDao = (NotificationDao)context.getBean("notificationDao");
Thanks for the suggestions.