Mr.J4mes
Mr.J4mes

Reputation: 9266

JSF 2.0: Why do I got this Inject managed bean Exception

I have the following 2 ManagedBean:

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

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

When I try to navigate to MakeReservation.xhtml, I saw the following exception:

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

Obviously, the scope of cartManagedBean is SessionScope. I have no idea why the Exception claimed that my bean has RequestScope. I have tried to Clean, Build and Run the Project several times but it didn't help.

I'd be very grateful if someone could show me where I have done wrong.

Best regards,

James Tran

Upvotes: 0

Views: 204

Answers (1)

kgautron
kgautron

Reputation: 8263

Be carreful to import the right package for your @SessionScoped annotation.

Upvotes: 2

Related Questions