title: @javax.faces.bean.ManagedProperty in CDI @Named bean returns null
body: <p>I'm trying to deal with <code>@javax.faces.bean.ManagedProperty</code> but without success !</p>
  <p>I've been following <a href="http://balusc.blogspot.it/2011/09/communication-in-jsf-20.html#InjectingManagedBeansInEachOther" rel="nofollow noreferrer">this</a> guide, and it not seems that hard.
  But my code simply won't work!</p>
  <p>Here's a little snippet</p>
  <pre><code>@ManagedBean
  @SessionScoped
  public class LoginBean {
  
      private User user;
  
      // ...
  }
  </code></pre>
  
  <pre><code>@Named
  @RequestScoped
  public class MessagesBean {
  
      @ManagedProperty(value = &quot;#{loginBean}&quot;)
      private LoginBean loginBean;
  
      public String getUser() {
          System.err.println(loginBean == null);
          return loginBean.getUser().getUsername();
      }
  
      // ...
  }
  </code></pre>
  <p>This code gives me a <code>NullPointerException</code>, saying that <code>loginBean</code> is null!</p>
  <p>Any suggestion?</p>