I have a web application built using JSF 2.2 and deployed on WebLogic 12.2.1.1.
I have set the session timeout in web.xml as 480 to keep it active for at least 8 hours.
<session-config>
<session-timeout>
480
</session-timeout>
</session-config>
However, still my web application times out within 15 minutes when kept idle. My LoginSession JSF managed bean defined in session scope is getting re-initialized.
@ManagedBean(name = "loginsession")
@SessionScoped
public class LoginSession implements Serializable {
private boolean userLoggedIn;
public LoginSession() {
}
public boolean isUserLoggedIn() {
return userLoggedIn;
}
public void setUserLoggedIn(boolean userLoggedIn) {
this.userLoggedIn = userLoggedIn;
}
}
userLoggedIn variable in LoginSession is set to true once the user logs into the application.
However, after 15 minutes when LoginSession is injected into a ViewScoped bean, userLoggedIn is turning out to be false and redirects me to the error page.
@ManagedBean(name = "home")
@ViewScoped
public class Home {
@ManagedProperty("#{loginsession}")
private LoginSession loginSession;
public Home() {
}
public void prepare() {
try {
if (!loginSession.isUserLoggedIn()) {
Exception ex = new Exception("User Not Logged In. Please <span class=\"text-bold text-danger\"><a href=\"/WebUtil/faces/login/index.xhtml\" class=\"text-danger\">RE-LOGIN</a></span> .");
Helper.redirectToErrorPage(ex, loginSession);
return;
}
}
}
public LoginSession getLoginSession() {
return loginSession;
}
public void setLoginSession(LoginSession loginSession) {
this.loginSession = loginSession;
}
}
I am not able to figure out the issue. I appreciate if some one can provide me a hint of what is happening. Thanks.
EDIT:
@ManagedBean(name = "login")
@RequestScoped
public class LoginPage {
@ManagedProperty("#{loginsession}")
private LoginSession loginSession;
public void setLoginSession(LoginSession bea) {
loginSession = bea;
}
public void prepare() {
loginSession.setUserLoggedIn(false);
}
public String submit() {
loginSession.setUserLoggedIn(true);
return "/faces/floor/Home.xhtml?faces-redirect=true";
}
}
submit() method is executed when the user enters credentials and clicks log in. prepare() is executed when the login page loads.
This issue is now resolved. It was an issue with load balancer redirecting to a different server after certain period of inactivity.