7 Replies Latest reply on Sep 25, 2005 12:15 PM by didi mann

    javax.faces.el.PropertyNotFoundException

    didi mann Newbie

      Hi,
      I'm trying to rebuild the registration app with Seam. Unfortunately it does not work. The deployment works, also it is displayed, but invoking the registration throws an exception (see below).
      Can somebody tell me why that is?

      My code is as follows:

      The action:

      @Stateless
      @Scope(EVENT)
      @Name("register2")
      @Interceptor(SeamInterceptor.class)

      public class RegisterAction implements Registrierung {

      @In @Valid
      private Student student;

      @PersistenceContext
      private EntityManager em;

      @In
      private FacesContext facesContext;

      @IfInvalid(outcome=Outcome.REDISPLAY)
      public String register()
      {
      List existing = em.createQuery("select username from Student where username=:username")
      .setParameter("username", student.getUserName())
      .getResultList();

      if (existing.size()==0)
      {
      em.persist(student);
      return "success";
      }
      else
      {
      facesContext.addMessage(null, new FacesMessage("username already exists"));
      return null;
      }
      }

      }



      LocalInterface:

      import javax.ejb.Local;

      @Local
      public interface Registrierung {

      public String register();
      }


      @Entity
      @Name("student")
      @Scope(SESSION)
      @Table(name="students")

      public class Student implements Serializable{

      /**
      *
      */
      private static final long serialVersionUID =-2866059835575212534L;

      public Student(){}
      public Student(String name, String username,String passwort){

      this.name=name;
      this.username=username;
      this.passwort=passwort;
      }


      //private String titel;
      @Basic
      private String username;
      @Basic
      private String name;
      @Basic
      private String passwort;


      public String getPasswort() {
      return passwort;
      }

      public void setPasswort(String passwort) {
      this.passwort = passwort;
      }

      public String getName() {
      // TODO Auto-generated method stub
      return name;
      }

      public void setName(String name) {
      // TODO Auto-generated method stub
      this.name=name;
      }

      @Id @NotNull @Length(min=5, max=15)
      public String getUserName() {
      return username;
      }

      public void setUserName(String user) {
      this.username = user;
      }

      }


      The jsf:

      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <html>
      <head>
      <title>Studentenregistrierung</title>
      </head>
      <body>
      <f:view>
      <h:form>
      <table border="0">
      <tr>
      <td>Username</td>
      <td><h:inputText value="#{student.username}"/></td>
      </tr>
      <tr>
      <td>Nachname</td>
      <td><h:inputText value="#{student.name}"/></td>
      </tr>
      <tr>
      <td>Passwort</td>
      <td><h:inputSecret value="#{student.passwort}"/></td>
      </tr>
      </table>
      <h:messages/>
      <h:commandButton type="submit" value="Register" action="#{register2.register}"/>
      </h:form>
      </f:view>
      </body>
      </html>




      Thrown Exception is:
      12:14:37,900 ERROR [ValueBindingImpl] Cannot set value for expression '#{student.passwort}' to a new value of type java.lang.String
      javax.faces.el.PropertyNotFoundException: Base is null: student
      at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:444)
      at org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:230)
      at javax.faces.component.UIInput.updateModel(UIInput.java:226)
      at javax.faces.component.UIInput.processUpdates(UIInput.java:165)
      at javax.faces.component.UIForm.processUpdates(UIForm.java:81)
      at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:416)
      at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:150)
      at org.apache.myfaces.lifecycle.LifecycleImpl.updateModelValues(LifecycleImpl.java:238)
      at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:81)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
      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.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
      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:856)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
      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)

      ...

      Thanks for any help!
      Dhoetschmann

        • 1. Re: javax.faces.el.PropertyNotFoundException
          Thomas Heute Master

          Did you try the registration example without modifying it first ?

          Your example cannot work, the getter and setter must follow the JavaBean notation rules.

          So please change the methods:
          getUserName to getUsername
          setUserName to setUsername

          Other than that there is no reason why it wouldn't work.

          Let me know if you still have troubles
          (Note that this is not related to your stacktrace)

          • 2. Re: javax.faces.el.PropertyNotFoundException
            didi mann Newbie

            Thank for the fast reply!

            Oops. Right. I have changed that.
            But it seems that this was not the fault.
            I still have the same exception.

            Best regards
            Dhoetschmann

            • 3. Re: javax.faces.el.PropertyNotFoundException
              Thomas Heute Master

              Did you try the registration example without modifying it first ?

              Did you specify the seam variable resolver in faces-config.xml ?
              (Copy web.xml and faces-config.xml from the examples)

              • 4. Re: javax.faces.el.PropertyNotFoundException
                Cloves Almeida Newbie

                I was having pretty much the same problem. I was using the jboss-microcontainer to run seam standalone in tomcat.

                The docs tells you to put the seam.properties file in the root of the archive. Weird, because when i have it in the WEB-INF/classes directory (and only there) it stops with the PropertyNotFoundException and goes on to another error:


                10:29:34,912 DEBUG Component:? - seam component not found: potyroDatabase
                10:29:34,920 ERROR MethodBindingImpl:162 - Exception while invoking expression #{loginAction.login}
                org.jboss.seam.RequiredException: In attribute requires value for component: potyroDatabase
                at org.jboss.seam.Component.getInstanceToInject(Unknown Source)
                at org.jboss.seam.Component.injectFields(Unknown Source)
                at org.jboss.seam.Component.inject(Unknown Source)
                at org.jboss.seam.interceptors.BijectionInterceptor.bijectTargetComponent(Unknown Sourc:



                where potyroDatabase is my jndi name for the SessionFactory.

                • 5. Re: javax.faces.el.PropertyNotFoundException
                  didi mann Newbie

                  The example runs without problems.
                  I used the xml files as templates for my own config.
                  I will post those files on Monday (am out of town the weekend) - I hope you can have a look at those files then.

                  Thanks
                  Dhoetschmann

                  • 6. Re: javax.faces.el.PropertyNotFoundException
                    Gavin King Master

                     

                    "cjalmeida" wrote:
                    I was having pretty much the same problem. I was using the jboss-microcontainer to run seam standalone in tomcat.

                    The docs tells you to put the seam.properties file in the root of the archive. Weird, because when i have it in the WEB-INF/classes directory (and only there) it stops with the PropertyNotFoundException and goes on to another error:


                    Seam uses the seam.properties file to find Seam component classes. You must have a seam.properties file in the root of any archive in which you have deployed Seam components.

                    The idea of this design is to save you from having to list the classes explicitly.

                    • 7. Re: javax.faces.el.PropertyNotFoundException
                      didi mann Newbie

                      Sorry. That (missing seam.properties file) was the problem!