title: Get real path of a file on JSF application startup
body: <p>I'm trying to get the real path of a file in a JSF application scoped Bean using :</p>
  
  <pre><code>FacesContext.getCurrentInstance().getExternalContext().getRealPath(file)
  </code></pre>
  
  <p>The problem is that <code>getCurrentInstance()</code> is throwing a <code>NullPointerException</code> when the bean is initialized at application startup:</p>
  
  <pre><code>@ManagedBean(eager = true)
  @ApplicationScoped
  public class EnvoiPeriodiqueApp implements Serializable {
  
      @PostConstruct
      public void initBean() {
          FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
      }
  
  }
  </code></pre>
  
  <p>So I'm trying to find another way to get the real path of the file without using the <code>getCurrentInstance()</code> of JSF.</p>
  
  <p>Any help will be appreciated.</p>