title: How to get a PortletPreferences without a request object
body: <p>I need to start a TimerTask that uses a PortletPreferences object.</p>
  
  <p>here's what I have for now (MyUpdateTask here extends TimerTask):</p>
  
  <pre><code>@ManagedBean(name = "myManagedBean", eager = true)
  @ApplicationScoped
  public class MyManagedBean implements Serializable {
      static MyUpdateTask updateTask;
  
      @PostConstruct
      public void init(){
          try {
              PortletPreferences portletPrefs = ((PortletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getPreferences();
              updateTask = new MyUpdateTask(portletPrefs);
              MyTaskService.getInstance().update(updateTask);
          } catch (Exception e) {
              e.printStackTrace(System.out);
          }
      }
  }
  </code></pre>
  
  <p><code>MyTaskService.update</code> uses a ScheduledExecutorService that generates a service to regularly update my data.</p>
  
  <p>the problem I have right now is that <code>((PortletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getPreferences();</code> throws an <strong>UnsupportedOperationException</strong> because there is currently no request. How can I get a PortletPreferences without a request?</p>
  
  <p>I do need a PortletPreferences object for the task. </p>