title: Unable to create managed bean UserBean - JSF
body: <p>I'm trying to create a simple login page that accesses a DB so that when username and password are validated, the id, firstName, lastName are set within the class as well for access. I get this error though: </p>
  
  <pre><code>javax.servlet.ServletException: Unable to create managed bean UserBean.  The following problems were found:
   - Property firstName for managed bean UserBean does not exist.  Check that appropriate getter and/or setter methods exist.
   - Property id for managed bean UserBean does not exist.  Check that appropriate getter and/or setter methods exist.
   - Property lastName for managed bean UserBean does not exist.  Check that appropriate getter and/or setter methods exist.
  javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
  </code></pre>
  
  <p>I have getters for id, firstName, lastName but no setters because they are set after validation.</p>
  
  <p>Here is class UserBean</p>
  
  <pre><code>public class UserBean {
  private static String password, username, id, firstName, lastName;
  public enum DBfields { BLANK, USERNAME, ID, PASSWORD, FIRSTNAME, LASTNAME }; 
  
  public String getPassword() {
      return password;
  }
  
  public void setPassword( String value ) {
      password = value;
  }
  
  public String getUsername() {
      return username;
  }
  
  public void setUsername( String value ) {
      username = value;
  }
  
  public static String getId() {
      return id;
  }
  
  public static String getFirstname() {
      return firstName;
  }
  
  public static String getLastname() {
      return lastName;
  }
  
  public String loginUser() throws Exception { 
  
      if( loginValidate( username, password ) )
          return "success";
      else
          return "fail";
  }
  
  public static boolean loginValidate( String username, String Password ) throws Exception{
  
      String DBuser;
      String DBpass = "asdf";
      PreparedStatement table = connectToTable( "firstsql", "users");
      ResultSet row = table.executeQuery();;
  
      while(row.next()){
          DBuser = row.getString(DBfields.USERNAME.name());
          if(username.equals(DBuser)){
              DBpass = row.getString(DBfields.PASSWORD.name());
              break;
          }
      }
  
      if(password.equals(DBpass)){
          id = row.getString(DBfields.ID.name());
          firstName = row.getString(DBfields.FIRSTNAME.name());
          lastName = row.getString(DBfields.LASTNAME.name());
          return true;
      } else
          return false;
  }
  </code></pre>
  
  <p>and my faces-config</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xi="http://www.w3.org/2001/XInclude"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"&gt;
   &lt;managed-bean&gt;
    &lt;managed-bean-name&gt;UserBean&lt;/managed-bean-name&gt;
    &lt;managed-bean-class&gt;com.jfsdemo.bean.UserBean&lt;/managed-bean-class&gt;
    &lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt;
    &lt;managed-property&gt;
     &lt;property-name&gt;firstName&lt;/property-name&gt;
     &lt;property-class&gt;java.lang.String&lt;/property-class&gt;
     &lt;value/&gt;
    &lt;/managed-property&gt;
    &lt;managed-property&gt;
     &lt;property-name&gt;id&lt;/property-name&gt;
     &lt;property-class&gt;java.lang.String&lt;/property-class&gt;
     &lt;value/&gt;
    &lt;/managed-property&gt;
    &lt;managed-property&gt;
     &lt;property-name&gt;lastName&lt;/property-name&gt;
     &lt;property-class&gt;java.lang.String&lt;/property-class&gt;
     &lt;value/&gt;
    &lt;/managed-property&gt;
    &lt;managed-property&gt;
     &lt;property-name&gt;password&lt;/property-name&gt;
     &lt;property-class&gt;java.lang.String&lt;/property-class&gt;
     &lt;value/&gt;
    &lt;/managed-property&gt;
    &lt;managed-property&gt;
     &lt;property-name&gt;username&lt;/property-name&gt;
     &lt;property-class&gt;java.lang.String&lt;/property-class&gt;
     &lt;value/&gt;
    &lt;/managed-property&gt;
   &lt;/managed-bean&gt;
   &lt;navigation-rule&gt;
    &lt;from-view-id&gt;/login.xhtml&lt;/from-view-id&gt;
    &lt;navigation-case&gt;
     &lt;from-action&gt;#{UserBean.loginUser}&lt;/from-action&gt;
     &lt;from-outcome&gt;success&lt;/from-outcome&gt;
     &lt;to-view-id&gt;/timesheet.xhtml&lt;/to-view-id&gt;
    &lt;/navigation-case&gt;
    &lt;navigation-case&gt;
     &lt;from-action&gt;#{UserBean.loginUser}&lt;/from-action&gt;
     &lt;from-outcome&gt;fail&lt;/from-outcome&gt;
     &lt;to-view-id&gt;/login.xhtml&lt;/to-view-id&gt;
    &lt;/navigation-case&gt;
   &lt;/navigation-rule&gt;
   &lt;navigation-rule&gt;
    &lt;from-view-id&gt;/timesheet.xhtml&lt;/from-view-id&gt;
   &lt;/navigation-rule&gt;
  &lt;/faces-config&gt;
  </code></pre>