问题
Null pointer exception is coming while trying to load application context while migrating to jsf 1.2.
Below is the stack trace
[ERROR] [com.sun.faces.lifecycle.InvokeApplicationPhase] [] - # {CustomerSearchBean.searchCustomers}: javax.faces.el.EvaluationException:
java.lang.NullPointerException
javax.faces.FacesException: #{CustomerSearchBean.searchCustomers}: javax.faces.el.EvaluationException: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
... 29 more
Caused by: java.lang.NullPointerException
at com.tms.cdqi.presentation.jsf.bean.customerprofile.CustomerSearchBean.searchCustomers(CustomerSearchBean.java:134)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
Below is the faces-xml
<managed-bean>
<description>This bean is used for customer profile</description>
<managed-bean-name>CustomerSearchBean</managed-bean-name>
<managed-bean-class>com.tms.cdqi.presentation.jsf.bean.customerprofile.CustomerSearchBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>commandInvoker</property-name>
<value>#{commandInvoker}</value>
</managed-property>
<managed-property>
<property-name>applicationContextFactory</property-name>
<value>#{cdqiApplicationContextFactory}</value>
</managed-property>
</managed-bean>
Edit 1: Below is the Application context xml
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="cdqiApplicationContextFactory"
class="com.tms.cdqi.framework.context.CDQIApplicationContextFactoryImpl" />
Edit 2 Code
The application context where null pointer is occurring
CDQIApplicationContext context = this.getApplicationContextFactory()
.getApplicationContext();
来源:https://stackoverflow.com/questions/28342750/nullpointerexception-while-trying-to-load-application-context-in-jsf-1-2