title: JSF ManagedProperty NullPointerException
body: <p>I have a <code>sessionScoped ManagedBean</code> in my JSF 2.2 project and i would like to invoke another <code>ManagedBean</code> as a <code>@ManagedProperty</code> This is my first <code>sessionScoped</code> bean:</p>
  
  <pre><code>public class MainWorkerMB implements Serializable {
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
  
      @ManagedProperty("#{fragmentHandlerMB}")
      private FragmentHandlerMB fragmentHandlerMB;
  
      public FragmentHandlerMB getFragmentHandlerMB() {
          return fragmentHandlerMB;
      }
  
      public void setFragmentHandlerMB(FragmentHandlerMB fragmentHandlerMB) {
          this.fragmentHandlerMB = fragmentHandlerMB;
      }
  
      public void search() {
  
          fragmentHandlerMB.changeFrag("search_result.xhtml" , "Result Page" , -1);
  
      }
  </code></pre>
  
  <p>This is my another bean this is also <code>sessionScoped</code>:</p>
  
  <pre><code>@ManagedBean(eager=true)
  @SessionScoped
  public class FragmentHandlerMB implements Serializable {
  
  @PostConstruct
      public void init() {
          log.info("constructed..");
          // other code parts //
  
      }
  
      public FragmentHandlerMB() {
          super();
      }
  
  public void changeFrag(String fragToOpen, String fragToOpenName, int pageIndex) {
  
  //...
  
  }
  }
  </code></pre>
  
  <p>After that when i try to invoke my secound bean method i got <code>NullPointerException</code>:</p>
  
  <pre><code>Caused By: java.lang.NullPointerException
      at com.kebodev.managed.MainWorkerMB.search(MainWorkerMB.java:29)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      Truncated. see log file for complete stacktrace
  </code></pre>
  
  <p>So it's looks like my bean doesn't exist.</p>
  
  <p>Can you help me?
  Thank you!</p>