2 Replies Latest reply on Mar 12, 2007 11:03 AM by Jörg Gottschlich

    NullPointerException when using <f:selectItem>

    Jörg Gottschlich Newbie

      Hi,

      I'm having a strange problem with the following code:

      <h:selectOneMenu id="anredebox" value="#{personalDataItem.anrede}" >
       <f:selectItem itemValue="#{msgs.interview_anrede_frau}" itemLabel="#{msgs.interview_anrede_frau}"/>
       <f:selectItem itemValue="#{msgs.interview_anrede_herr}" itemLabel="#{msgs.interview_anrede_herr}"/>
      </h:selectOneMenu>
      


      Backing Bean (extract):
      @Entity
      @Name("personalDataItem")
      @Scope(SESSION)
      /**
       * Class PersoenlicheDatenItem
       */
      public class PersoenlicheDatenItem extends CategoryItem implements PersoenlicheDatenItemInterface, Serializable {
      
       //
       // Fields
       //
      
       /**
       * Anrede "Frau" oder "Herr"
       */
       @NotNull
       private String anrede;
      

      Of course, there is an interface with appropriate getters and setters.

      When I'm submitting the form, I receive the following exception:
      java.lang.NullPointerException: value
       at javax.faces.model.SelectItem.<init>(SelectItem.java:71)
       at javax.faces.component._SelectItemsIterator.hasNext(_SelectItemsIterator.java:72)
       at javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:46)
       at javax.faces.component.UISelectOne.validateValue(UISelectOne.java:62)
       at javax.faces.component.UIInput.validate(UIInput.java:353)
       at javax.faces.component.UIInput.processValidators(UIInput.java:183)
       at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
       at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
       at javax.faces.component.UIForm.processValidators(UIForm.java:70)
       at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:624)
       at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:146)
       at org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(LifecycleImpl.java:262)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       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.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
       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.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      


      I wonder what I'm doing wrong, since I've seen such code in other examples where it seems to work. I'm also using <h:selectOneMenu>s with SelectItems provided by server-sided Beans and those work properly. Isn't it possible to generate selectItems like this?

      Thanks for any help in advance!
      Regards,
      Jörg

      Seam-Version is 1.2.0PATCH1. JBoss is 4.0.5GA.