Take the 2-minute tour ×

I have a strange problem. Afaik I can inject a SessionScoped bean into a viewscoped, because its broader, than the other. Here is my code:

public class ProjectBean implements Serializable {

private ProjectCurrentBean currentBean;

public void setCurrentBean(ProjectCurrentBean currentBean) {
    this.currentBean = currentBean;

private UserCredentialsBean activeUser;

public void setActiveUser(UserCredentialsBean activeUser) {
    this.activeUser = activeUser;

The 2 managed bean:

public class ProjectCurrentBean implements Serializable  {


public class UserCredentialsBean  implements Serializable {

It works fine with the UserCredentialsBean, but when I put the ProjectCurrentBean it fails:

Unable to create managed bean projectBean. The following problems were found: - The scope of the object referenced by expression #{projectCurrentBean}, request, is shorter   than the referring managed beans (projectBean) scope of view

why? :)

share|improve this question
add comment

1 Answer

up vote 11 down vote accepted

You've not declared the bean using @SessionScoped from javax.faces.bean package, but instead from javax.enterprise.context package. This don't work in combination with @ManagedBean from javax.faces.bean package. The bean will then default to the request scope and behave like @RequestScoped.

Fix your imports.

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

public class ProjectCurrentBean implements Serializable {
share|improve this answer
omg, thank you! what a mistake –  kristu Nov 19 '11 at 16:24
Be careful with IDE autocomplete. –  BalusC Nov 19 '11 at 16:28
add comment

Your Answer


