title: JSF2.0 @ManagedProperty - Target Unreachable returned null
body: <p>i am useing a @ManagedProperty in JSF 2.0 but i am getting a below problem.</p>
  
  <p><strong>Entity Class</strong></p>
  
  <pre><code>@Entity(name="UserDetail")
  @Table(name="in_user")
  @SessionScoped
  public class UserDetail implements Serializable{
  
      private static final long serialVersionUID = 1L;
  
      @Id
      private Integer no;
      private String userName;
      private String password;
  
  
      public Integer getNo() {
          return no;
      }
      public void setNo(Integer no) {
          this.no = no;
      }
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
  
  
  }
  </code></pre>
  
  <p><strong>Controller</strong> </p>
  
  <pre><code>@ManagedBean(name="authenticator")
  @RequestScoped
  public class Authenticator implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @ManagedProperty(value = "#{userDetail}")
      private UserDetail userDetail;
  
          // Some Code......
  }
  </code></pre>
  
  <p><strong>.XHTML</strong></p>
  
  <pre><code>&lt;p:panel header="Application Login" toggleable="true" toggleOrientation="horizontal" style="width:400px"&gt;
                  &lt;p:panelGrid columns="2" columnClasses="0"&gt;
                      &lt;h:outputLabel value="User Name " /&gt;
                      &lt;h:inputText value="#{authenticator.userDetail.userName}" /&gt;
  
                      &lt;h:outputLabel value="Password " /&gt;
                      &lt;h:inputSecret value="#{authenticator.userDetail.password}" /&gt;
  
                      &lt;p:commandButton value="Login" action="#{authenticator.authenticate}"&gt;&lt;/p:commandButton&gt;
                      &lt;p:commandButton value="Log Out" action="#{authenticator.logOut}" /&gt;
                  &lt;/p:panelGrid&gt;
              &lt;/p:panel&gt;
  </code></pre>
  
  <p>when i execute the application, i am facing below problem..</p>
  
  <pre><code>Mar 29, 2013 7:26:56 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
  WARNING: /login.xhtml @21,66 value="#{authenticator.userDetail.userName}": Target Unreachable, 'userDetail' returned null
  javax.el.PropertyNotFoundException: /login.xhtml @21,66 value="#{authenticator.userDetail.userName}": Target Unreachable, 'userDetail' returned null
      at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
      at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
      at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
      at javax.faces.component.UIInput.validate(UIInput.java:960)
      at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
      at javax.faces.component.UIInput.processValidators(UIInput.java:698)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at org.primefaces.component.panel.Panel.processValidators(Panel.java:297)
      at javax.faces.component.UIForm.processValidators(UIForm.java:253)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
      at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
      at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  </code></pre>
  
  <p>i don't know where is the problem.</p>
  
  <p>if i replace.</p>
  
  <pre><code>@ManagedProperty(value = "#{userDetail}")
      private UserDetail userDetail;
  </code></pre>
  
  <p>with</p>
  
  <pre><code>private UserDetail userDetail = new UserDetail();
  </code></pre>
  
  <p>then it's work fine. but i want to use @ManagedProperty. please help me.</p>