title: @ManagedProperty does not work in a CDI managed bean
body: <p>I try to learn JSF and encountered on a problem connected with ManagedProperty. However I have tried to use it, it always failed - null exception pointer. What am I doing wrongly?
  I have read some "similar posts" on stackoverflow, but they did not helped to me. (I use GlassFish 4.0, JSF 2.2, JDK 1.7, Netbeans 7.3.1 (Java EE pack) and Java EE 6.0)</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://xmlns.jcp.org/jsf/html"&gt;
      &lt;h:head&gt;
      &lt;title&gt;Facelet Title&lt;/title&gt;
      &lt;/h:head&gt;
      &lt;h:body&gt;
      Hello from Facelets
      &lt;br/&gt;
      User: #{books.user.name}&lt;br/&gt;
      1: #{param.pageId}&lt;br/&gt;
      2: #{books.pageId}&lt;br/&gt;
      &lt;h:form&gt;
          &lt;h:inputText value="#{user.name}" /&gt;&lt;br/&gt;
          &lt;h:inputText value="#{books.v1}" /&gt;&lt;br/&gt;
          &lt;h:inputText value="#{books.v2}" /&gt;&lt;br/&gt;
          &lt;h:inputText value="#{books.result}" /&gt;&lt;br/&gt;
          &lt;h:commandButton value="dodaj" action="#{books.add}" /&gt;
      &lt;/h:form&gt;
      &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Book</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package tpsa.books.managed;
  
  import javax.inject.Named;
  import javax.enterprise.context.RequestScoped;
  import javax.faces.bean.ManagedProperty;
  
  /**
   *
   * @author tomasz
   */
  @Named(value = "books")
  @RequestScoped
  public class Books {
  
      private int v1;
      private int v2;
      private int result;
      @ManagedProperty(value = "#{user}")
      private User user;
  
      @ManagedProperty(value="#{param.pageId}")
      private int pageId;
  
      /**
       * Creates a new instance of Books
       */
      public Books() {
      }
  
      public void add() {
      result = v1 + v2;
  
      }
  
      public int getV1() {
      return v1;
      }
  
      public void setV1(int v1) {
      this.v1 = v1;
      }
  
      public int getV2() {
      return v2;
      }
  
      public void setV2(int v2) {
      this.v2 = v2;
      }
  
      public int getResult() {
      return result;
      }
  
      public void setResult(int result) {
      this.result = result;
      }
  
      public User getUser() {
      if (user == null) {
          System.err.println("WTF");
      }
      return user;
      }
  
      public void setUser(User user) {
      this.user = user;
      }
  
      public int getPageId() {
      return pageId;
      }
  
      public void setPageId(int pageId) {
      this.pageId = pageId;
      }
  
  
  
  }
  </code></pre>
  
  <p>User</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package tpsa.books.managed;
  
  import javax.inject.Named;
  import javax.enterprise.context.SessionScoped;
  import java.io.Serializable;
  
  /**
   *
   * @author tomasz
   */
  @Named(value = "user")
  @SessionScoped
  public class User implements Serializable {
  
      private String name;
  
      /**
       * Creates a new instance of User
       */
      public User() {
      }
  
      public String getName() {
      return name;
      }
  
      public void setName(String name) {
      this.name = name;
      }
  
  
  
  }
  </code></pre>