JSF 2.0:为什么我得到这个Inject托管bean异常

时间:2011-10-27 08:20:55

标签: java exception jsf-2 scope

我有以下2个ManagedBean:

@ManagedBean
@ViewScoped
public class MakeReservation {
    ...
    @ManagedProperty(value="#{cartManagedBean}")
    private CartManagedBean cartSession;
    ...
}

@ManagedBean
@SessionScoped
public class CartManagedBean {
    ...
}

当我尝试导航到MakeReservation.xhtml时,我看到了以下异常:

SEVERE: JSF will be unable to create managed bean makeReservation when it is requested.  The following problems where found:
     - The scope of the object referenced by expression #{cartManagedBean}, request, is shorter than the referring managed beans (makeReservation) scope of view

显然,cartManagedBean的范围是SessionScope。我不知道为什么Exception声称我的bean有RequestScope。我曾多次尝试清理,构建和运行项目,但没有帮助。

如果有人能告诉我我做错了什么,我将非常感激。

致以最诚挚的问候,

James Tran

1 个答案:

答案 0 :(得分:2)

请谨慎导入@SessionScoped注释的正确包。