title: Can't @Inject a @ManagedBean in another @ManagedBean
body: <p>Ok here is my session bean.  I can always retrieve the currentUser from any Servlet or Filter.  That's not the problem  The problem is the fileList, and currentFile.  I've tested with simple int's and Strings and its' the same effect.  If I set a value from my view scoped bean I can get the data from another class.   </p>
  
  <pre><code>@ManagedBean(name = "userSessionBean")
  @SessionScoped
  public class UserSessionBean implements Serializable, HttpSessionBindingListener {
  
      final Logger logger = LoggerFactory.getLogger(UserSessionBean.class);
  
      @Inject
      private User currentUser;
  
      @EJB
      UserService userService;
  
      private List&lt;File&gt; fileList;   
  
      private File currentFile;
  
      public UserSessionBean() {
  
          fileList = new ArrayList&lt;File&gt;();
          currentFile = new File("");
      }
  
      @PostConstruct
      public void onLoad() {
  
          Principal principal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
          String email = principal.getName();
  
          if (email != null) {
              currentUser = userService.findUserbyEmail(email);
          } else {
  
              logger.error("Couldn't find user information from login!");
          }
      }
  </code></pre>
  
  <p>Here is an example.</p>
  
  <p>My view scoped bean.  This is how it is decorated.</p>
  
  <pre><code> @ManagedBean
   @ViewScoped
   public class ViewLines implements Serializable {
  
      @Inject
      private UserSessionBean userSessionBean; 
  </code></pre>
  
  <p>Now the code.</p>
  
  <pre><code>    userSessionBean.setCurrentFile(file);
      System.out.println("UserSessionBean : " + userSessionBean.getCurrentFile().getName());
  </code></pre>
  
  <p>I can see the current file name perfectly.  This is actually being printed from a jsf action method.  So obviously the currentFile is being set.</p>
  
  <p>Now if I do this.</p>
  
  <pre><code>@WebFilter(value = "/Download")
  public class FileFilter implements Filter {
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {        
          HttpSession session = ((HttpServletRequest) request).getSession(false);
          UserSessionBean userSessionBean = (UserSessionBean) session.getAttribute("userSessionBean");       
  
          System.out.println(userSessionBean.getCurrentUser().getUserId()); //works
  
          System.out.println("File filter" + userSessionBean.getCurrentFile().getName()); //doesn't work
  
  
          chain.doFilter(request, response);
      }
  
      @Override
      public void init(FilterConfig filterConfig) throws ServletException {
      }
  
      @Override
      public void destroy() {
      }
  }
  </code></pre>
  
  <p>currentUser shows up fine but I can't see the file.  It's just blank.  The same thing happens with Strings, int's, etc.</p>
  
  <p>Thanks for any help you can provide on this. </p>
  
  <p>INFO: UserSessionBean : Line 3B--8531268875812004316.csv (value printed from view scoped bean)</p>
  
  <p>INFO: File filter tester.csv (value printed when filter is ran.)</p>
  
  <h1>**EDIT**</h1>
  
  <p>This worked.</p>
  
  <pre><code> FacesContext context = FacesContext.getCurrentInstance();
      userSessionBean = (UserSessionBean) context.getApplication().evaluateExpressionGet(context, "#{userSessionBean}", UserSessionBean.class);
  </code></pre>
  
  <p>I put this in the constructor of the ViewScoped and everything was fine.  Now why isn't the inject doing what I thought?  At first I thought maybe because I was using JSF managed beans instead of the new CDI beans.  But I changed the beans to the new style(with named) and that was the same effect.</p>
  
  <p>Does the inject only allow you to access the beans but not change their attributes?</p>