title: Injecting Beans in JSF 2.0
body: <p>I have a Session scoped bean</p>
  
  <pre><code>import javax.faces.bean.SessionScoped;
  import javax.inject.Named;
  @Named
  @SessionScoped
  public class SessionBean implements Serializable{
  </code></pre>
  
  <p>I inyect the object in one Filter...</p>
  
  <pre><code>public class FiltroSeguridad implements Filter{
  
  @Inject
  private SessionBean sessionBean;
  
  @Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    sessionBean.setRutaRedirect(httpRequest.getRequestURI());
  }
  }
  </code></pre>
  
  <p>But, I inyect SessionBean in the next interaction...</p>
  
  <pre><code>@Model
  public class CuentaUsuarioWebBean implements Serializable{
   @Inject
   private SessionBean sessionBean;
  
  public void loginUsuario() throws IOException{
     sessionBean.getRutaRedirect();
  }
  
  }
  </code></pre>
  
  <p>But the property <code>getRutaRedirect()</code> returns null</p>
  
  <p>I change the import by CDI annotations it still doesn't work (<code>javax.enterprise.context.SessionScoped</code>), same with JSF annotation (<code>javax.faces.bean.ManagedBean</code> and <code>@ManagedProperty</code>).</p>
  
  <p>Thanks.</p>
  
  <p>PD: Sorry for my English!</p>