Here is the managed bean declaration:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean(name = "user")
@SessionScoped
public class UserConsoleAction extends UserAction implements Serializable {
And the following code from servlet returns null:
UserConsoleAction uca = (UserConsoleAction) req.getSession().getAttribute("user");
This is an old code written on JSF 1 and now JSF 2.2 is using. This was working fine & able to get session scoped managed bean from session when managed bean was declared in faces-config.xml.
<managed-bean>
<description>Used for user console functions</description>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>com.web.admin.UserConsoleAction</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
But when I removed this faces-config.xml entry & used ManagedBean annotation, the code to get managed bean instance from session returns null. What may be the cause for this change since it is only the declaration part changed from xml to annotation.
ManagedBean annotation worked fine when extends UserAction is removed. UserAction is a request scoped bean & UserConsoleAction is session scoped.