title: Property [surname] not found on type [controller.AppController]. Why?
body: <p>I am trying to complete the implementation of a user account database including the registration process. Sadly, hibernate does not seem to find the necessary properties.</p>
  <p>During a study, I was challenged to save passwords securely in a given database. This part is deleted in the source code. (It happened not to be a problem, but other study members could be influenced.) I've already tried to comment / uncomment the ManagedProperty annotations in AppController.java and AppUser.java in all possible combinations, but none of them seemed to lead me further to a solution. Only &quot;circular reference&quot; messages were added.</p>
  <p>Many other SE questions concerning the same issue seem to having neglected the correct naming of their getter or setter methods or the correct annotation syntax, but this seems not to be the problem in my case.</p>
  <p>It's my first use of hibernate, thus I'm somewhat lost. (E. g., I do not know if the annotation must be set exactly before the declaration of the annotated variable.) The renaming of AppController.hbm.xml to Appuser.hbm.xml does not solve the problem either.</p>
  <p>I hope that the problem is easy enough to be seen by experts like you, since a complete minimal example would have rather many files to present.</p>
  <p>Appuser.java:</p>
  <pre class="lang-java prettyprint-override"><code>package model;
  
  import javax.faces.bean.ManagedProperty;
  import javax.persistence.*;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Size;
  import java.util.Date;
  import org.hibernate.validator.constraints.NotBlank;
  
  @Entity
  @Table(name=&quot;APPUSER&quot;)
  public class Appuser {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int id;
  
      @Size(min=3, max=50)
      @Column(name = &quot;FIRSTNAME&quot;, nullable = false)
      @ManagedProperty(value = &quot;#{appController.firstname}&quot;)
      private String firstname;
      
      @Size(min=3, max=50)
      @Column(name = &quot;SURNAME&quot;, nullable = false)
      @ManagedProperty(value = &quot;#{appController.surname}&quot;)
      private String surname;
  
      @NotNull
      @Column(name = &quot;BIRTHDATE&quot;, nullable = false)
      private Date birthdate; 
      
      @NotBlank
      @Column(name = &quot;EMAIL&quot;, nullable = false)
      private String email;
      
      @NotBlank
      @Column(name = &quot;GENDER&quot;, nullable = false)
  //    @ManagedProperty(value = &quot;#{appController.gender}&quot;)
  
      private String gender;
      
      @NotBlank
      @Column(name = &quot;USERNAME&quot;, nullable = false)
      private String username;
      
      @NotBlank
      @Column(name = &quot;SALTED_HASED_PW&quot;, nullable = false)
      private String salted_hash;
      
      @NotBlank
      @Column(name = &quot;SALT&quot;, nullable = false)
      private byte[] salt;
      
      public Appuser() {
          firstname = new String();
          surname = new String();
          birthdate = new Date();
          email = new String();
          username = new String();
          salted_hash = new String();
          salt = new byte[64];
      }
      
      public byte[] getSalt() {
          return salt;
      }
  
      public void setSalt(byte[] salt) {
          this.salt = salt;
      }
  
      public String getFirstname() {
          return firstname;
      }
  
      public void setFirstname(String firstname) {
          this.firstname = firstname;
      }
  
      public String getSurname() {
          return surname;
      }
  
      public void setSurname(String surname) {
          this.surname = surname;
      }
  
      public Date getBirthdate() {
          return birthdate;
      }
  
      public void setBirthdate(Date birthdate) {
          this.birthdate = birthdate;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getGender() {
          return gender;
      }
  
      public void setGender(String gender) {
          this.gender = gender;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getSalted_hash() {
          return salted_hash;
      }
  
      public void setSalted_hash(String salted_hash) {
          this.salted_hash = salted_hash;
      }
  }
  </code></pre>
  <p>AppController.java:</p>
  <pre class="lang-java prettyprint-override"><code>package controller;
  
  
  import java.beans.Transient;
  import java.util.Date;
  
  import javax.faces.application.FacesMessage;
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.ManagedProperty;
  import javax.faces.bean.RequestScoped;
  import javax.faces.context.FacesContext;
  import java.security.SecureRandom;
  import javax.crypto.SecretKeyFactory;
  import javax.crypto.spec.SecretKeySpec;
  import javax.crypto.SecretKey;
  
  // ... security imports
  
  import model.Appuser;
  import dao.UserDAO;
  
  @ManagedBean(name = &quot;appController&quot;, eager = true)
  @RequestScoped
  public class AppController{
  
      private byte salt[] = new byte[64];
      
  //    @ManagedProperty(value = &quot;#{appController.firstname}&quot;)
      private UserDAO dao;
      private String firstname;
  //    @ManagedProperty(value = &quot;#{appController.surname}&quot;)
      private String surname;
  //    @ManagedProperty(value = &quot;#{appController.birthdate}&quot;)
      private Date birthdate;
  //    @ManagedProperty(value = &quot;#{appController.email}&quot;)
      private String email;
  //    @ManagedProperty(value = &quot;#{appController.gender}&quot;)
      private String gender;
  //    @ManagedProperty(value = &quot;#{appController.username}&quot;)
      private String username;
  //    @ManagedProperty(value = &quot;#{appController.password}&quot;)
      private String password;
      
      public String registration() {
          return &quot;registration&quot;;
      }
      
      public boolean saveUser() throws NoSuchAlgorithmException, InvalidKeySpecException {
          Appuser newUser = new Appuser();
          newUser.setFirstname(firstname);
          newUser.setSurname(surname);
          newUser.setBirthdate(birthdate);
          newUser.setEmail(email);
          newUser.setGender(gender);
          newUser.setUsername(username);
          
          newUser.setSalt(salt);
          // use of a crypto library to generate a variable k not relevant for the issue
          newUser.setSalted_hash(k.getClass().descriptorString());
          boolean had_success = dao.save(newUser);
          if (had_success == false) {
              System.out.println(&quot;There occured an error. Most probably, the username is yet in the database.&quot;);
              return false;
          }
          else
              return true;
      }
  }
  </code></pre>
  <p>AppController.hbm.xml:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot;?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC 
  &quot;-//Hibernate/Hibernate Mapping DTD//EN&quot;
  &quot;http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd&quot;&gt; 
  
  &lt;hibernate-mapping&gt;
     &lt;class name = &quot;Appuser&quot; table = &quot;APPUSER&quot;&gt;
        
        &lt;meta attribute = &quot;class-description&quot;&gt;
           This class contains the app user detail. 
        &lt;/meta&gt;
        
        &lt;id name = &quot;id&quot; type = &quot;int&quot; column = &quot;id&quot;&gt;
           &lt;generator class=&quot;native&quot;/&gt;
        &lt;/id&gt;
        
        &lt;property name = &quot;firstname&quot; column = &quot;FIRSTNAME&quot; type = &quot;string&quot;/&gt;
        &lt;property name = &quot;surname&quot; column = &quot;SURNAME&quot; type = &quot;string&quot;/&gt;
        &lt;property name = &quot;birthdate&quot; column = &quot;BIRTHDATE&quot; type = &quot;date&quot;/&gt;
         &lt;property name = &quot;email&quot; column = &quot;EMAIL&quot; type = &quot;string&quot;/&gt;
          &lt;property name = &quot;gender&quot; column = &quot;GENDER&quot; type = &quot;string&quot;/&gt;
           &lt;property name = &quot;username&quot; column = &quot;USERNAME&quot; type = &quot;string&quot;/&gt;
            &lt;property name = &quot;salted_hash&quot; column = &quot;SALTED_HASHED_PW&quot; type = &quot;string&quot;/&gt;
             &lt;property name = &quot;salt&quot; column = &quot;SALT&quot; type = &quot;byte&quot;/&gt;
        
     &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  <p>registration.xhtml:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;!DOCTYPE html&gt;
  
  &lt;html lang=&quot;en&quot;
        xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
        xmlns:h=&quot;http://java.sun.com/jsf/html&quot;
        xmlns:f=&quot;http://java.sun.com/jsf/core&quot;
        xmlns:a=&quot;http://xmlns.jcp.org/jsf/passthrough&quot;&gt;
        
      &lt;h:head&gt;
          &lt;title&gt;SportSnapShare&lt;/title&gt;
          
          &lt;link href=&quot;resources/css/bootstrap.min.css&quot; rel=&quot;stylesheet&quot;/&gt;
          &lt;link href=&quot;resources/css/common.css&quot; rel=&quot;stylesheet&quot;/&gt;  
      &lt;/h:head&gt;
      
      &lt;h:body&gt;
          
         &lt;div class=&quot;containerReg&quot;&gt;
         &lt;/div&gt;
          &lt;div class=&quot;content&quot;&gt;
          &lt;h:form id=&quot;userForm&quot; class=&quot;form-signin&quot;&gt;  
          
          &lt;h2 class=&quot;form-signin-heading&quot;&gt;SportSnapShare Registration&lt;/h2&gt;           
  
              &lt;h:inputText id=&quot;sname&quot; type=&quot;text&quot; value=&quot;#{appController.surname}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;Surname&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your last name&quot;/&gt;
              &lt;h:message for=&quot;sname&quot; style=&quot;color:red&quot; /&gt;&lt;br/&gt;    
                      
              &lt;h:inputText id=&quot;fname&quot; type=&quot;text&quot; value=&quot;#{appController.firstname}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;Firstname&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your first name&quot;/&gt;
              &lt;h:message for=&quot;fname&quot; style=&quot;color:red&quot; /&gt;&lt;br/&gt;
              
              &lt;div class=&quot;form-group&quot;&gt;
              &lt;h:selectOneRadio id=&quot;gender&quot; value=&quot;#{appController.gender}&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your gender&quot;&gt;
                  &lt;f:selectItem itemValue=&quot;female&quot; itemLabel=&quot;Female&quot; /&gt;              
                  &lt;f:selectItem itemValue=&quot;male&quot; itemLabel=&quot;Male&quot; /&gt;
              &lt;/h:selectOneRadio&gt;
              &lt;h:message for=&quot;gender&quot; style=&quot;color:red&quot; /&gt;
              &lt;/div&gt;
              
              &lt;h:inputText id=&quot;bday&quot; type=&quot;text&quot; value=&quot;#{appController.birthdate}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;Date of Birth (dd.mm.yyyy)&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your date of birth&quot;&gt;
              &lt;f:convertDateTime pattern=&quot;dd.MM.yyyy&quot; /&gt;
              &lt;/h:inputText&gt;
              &lt;h:message for=&quot;bday&quot; style=&quot;color:red&quot; /&gt;&lt;br/&gt;
              
              &lt;h:inputText id=&quot;email&quot; type=&quot;text&quot; value=&quot;#{appController.email}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;E-Mail&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your email&quot;/&gt;
              &lt;h:message for=&quot;email&quot; style=&quot;color:red&quot; /&gt;&lt;br/&gt;
              
              &lt;h:inputText id=&quot;uname&quot; type=&quot;text&quot; value=&quot;#{appController.username}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;Username&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your username&quot; /&gt;
              &lt;h:message for=&quot;uname&quot; style=&quot;color:red&quot; /&gt;
              &lt;h:messages styleClass=&quot;errorMessage&quot; style=&quot;color:red&quot; globalOnly=&quot;true&quot;/&gt;&lt;br/&gt;
              
              &lt;h:inputSecret id=&quot;pssw&quot; type=&quot;text&quot; value=&quot;#{appController.password}&quot; class=&quot;form-control&quot; 
              a:placeholder=&quot;Password&quot; required=&quot;true&quot; requiredMessage=&quot;Please enter your password&quot;/&gt;
              &lt;h:message for=&quot;pssw&quot; style=&quot;color:red&quot; /&gt;&lt;br/&gt;
  
  
              &lt;h:commandButton class=&quot;btn btn-lg btn-primary btn-block&quot; value=&quot;Submit&quot; action=&quot;#{appController.saveUser}&quot;/&gt;
          &lt;/h:form&gt;
          &lt;/div&gt;
          &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js&quot;&gt;&lt;/script&gt;
          &lt;script src=&quot;resources/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
  
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>The expected output after &quot;Run on server&quot; in Eclipse should be the registration site, which allows me to create some test user accounts and save them securely into a database (which I can access and therefore control the result).</p>
  <p>The actual output is a HTTP error message site with the message</p>
  <p>&quot;Message /registration.xhtml @27,91 value=&quot;#{appController.surname}&quot;: Property [surname] not found on type [controller.AppController]&quot;</p>
  <p>followed by:</p>
  <pre><code>Exception
  javax.servlet.ServletException: /registration.xhtml @27,91 value=&quot;#{appController.surname}&quot;: Property [surname] not found on type [controller.AppController]
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
  Root Cause
  javax.el.PropertyNotFoundException: /registration.xhtml @27,91 value=&quot;#{appController.surname}&quot;: Property [surname] not found on type [controller.AppController]
      com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      javax.faces.component.UIOutput.getValue(UIOutput.java:174)
      javax.faces.component.UIInput.getValue(UIInput.java:291)
      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
      javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
  Root Cause
  javax.el.PropertyNotFoundException: Property [surname] not found on type [controller.AppController]
      javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:260)
      javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:212)
      javax.el.BeanELResolver.property(BeanELResolver.java:347)
      javax.el.BeanELResolver.getValue(BeanELResolver.java:92)
      com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
      com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
      org.apache.el.parser.AstValue.getValue(AstValue.java:169)
      org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:190)
      com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
      javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
      javax.faces.component.UIOutput.getValue(UIOutput.java:174)
      javax.faces.component.UIInput.getValue(UIInput.java:291)
      com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:355)
      com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:164)
      javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
      javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
      javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456)
      com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133)
      com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
      com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
      javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
  Hinweis Der komplette Stacktrace der Ursache ist in den Server logs zu finden
  </code></pre>
  <p>This messages seem not to contain a concrete reference to any (potentially faulty) file in my project. The relevant server logs seem to be not created for the current day (despite I did not change Tomcat's configuration).</p>
  <p>My folder structure can be viewn here:
  <a href="https://imgur.com/rCPL03i" rel="nofollow noreferrer"><img src="https://imgur.com/rCPL03i" alt="My folder structure" /></a>
  (I was not able to insert an image with the guided editor despite knowing the theory.)</p>
  <p>Many thanks in advance!</p>