title: Access JSF2 Managed Bean from RESTful Web Service
body: <p>I have an application scoped managed bean which contains a list read from the database. Whenever another application makes changes to the database, it should trigger the web service to update the list in the managed bean.</p>
  
  <p>I've tried</p>
  
  <pre><code>FacesContext context = FacesContext.getCurrentInstance();
  ApplicationBean application= (ApplicationBean) context.getApplication().evaluateExpressionGet(context, "#{applicationBean}", ApplicationBean.class);
  </code></pre>
  
  <p>The context variable was null, probably because the web service isn't called in the JSF context.</p>
  
  <p>The REST resource class looks something like this:</p>
  
  <pre><code>@Path("/application")
  public class ApplicationResource {
  
  @PUT
  @Path("{id}")
  @Consumes(MediaType.TEXT_PLAIN)
  @Produces(MediaType.TEXT_PLAIN)
  public void updateIdCache(@PathParam("id") String internalid) {
      ApplicationBean application = ???;
      application.update(id);
      return;
  }
  
  }
  </code></pre>
  
  <p>The application server in use is tomcat 6. How is it done correctly?</p>
  
  <p>Thanks &amp; best regards</p>