javax.faces.FacesException: javax.el.ELException:
843844Mar 23 2007 — edited Mar 23 2007Greetings All,
I am pretty new to JSF, and I have been stuck on a problem for the past few days now. I can't figure out what I am doing wrong, but it seems like it should not be this difficult. I am trying to get a selectOneMenu drop down box to work. The following is the snippet of code from the xhtml file:
<h:selectOneMenu value="#{siteSelector.searchType}" id="searchType">
<f:selectItems value="#{siteSelector.searchList}"/>
</h:selectOneMenu>
The following is the snippet of code from my "SiteSelector" class:
private static final String SITE_NUMBER = "SiteNumber";
private static final String SITE_NAME = "SiteName";
private static final String CUSTOMER_ID = "CustomerId";
private SelectItem[] searchList;
public SelectItem[] getSearchList() {
searchList[0] = new SelectItem(SITE_NUMBER, SITE_NUMBER);
searchList[1] = new SelectItem(SITE_NAME, SITE_NAME);
searchList[2] = new SelectItem(CUSTOMER_ID, CUSTOMER_ID);
return searchList;
}
And finally, the following is the code from the log file:
SEVERE: Error Rendering View[pages/site_inquiry.xhtml]
javax.faces.FacesException: javax.el.ELException: /pages/site_inquiry.xhtml @30,59 value="#{siteSelector.searchList}": java.lang.NullPointerException
at javax.faces.component.UISelectItems.getValue(UISelectItems.java:133)
at com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:359)
at com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:507)
at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:482)
at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:447)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:848)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:893)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:828)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:883)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:889)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:578)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:133)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:244)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.el.ELException: /pages/site_inquiry.xhtml @30,59 value="#{siteSelector.searchList}": java.lang.NullPointerException
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
... 29 more
Caused by: java.lang.NullPointerException
at com.gfs.gfsplus.view.SiteSelector.getSearchList(SiteSelector.java:59)
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:585)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:218)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:135)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:62)
at com.sun.el.parser.AstValue.getValue(AstValue.java:117)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 30 more
I have the Bean setup and working, I am just trying to get the drop down list working so that I get the value into the "SiteSelector" class. If I remove the SelectOneMenu from the xhtml file, my app works as designed.
Would anyone have thoughts as to why I am getting the null pointer exception?