在我的Vaadin应用程序中,当“会话超时”消息之后Vaadin不会使会话无效时出现问题。得到这个消息后,用户有时可以单击链接或刷新页面并继续工作,就好像他们仍然被登录 我使用下列参数:有时,Vaadin不会在“会话超时”消息之后使会话无效
closeIdleSessions=true
heartbeatInterval=60
session-timeout=15
末参数(会话超时)是因为我没有从vaadin文档中得到清楚的结果,它在context.xml(session-timeout = 900)和web.xml(session-config/session-timeout = 15)中设置,是否有这样的vaadin servlet参数。
有人问题吗?
UPDATE 1:固定参数片段。
UPDATE 2:SessionDestroyListener.sessionDestroy
在出现Session expired
消息时未触发。
UPDATE 3:之前的错误是由于代码错误而出现的。现在SessionDestroyListener.sessionDestroy
被调用,但我无法访问给定事件中的HttpSession
。
这里是我的SessionDestroyListener
代码(请注意,if
的一个分支评论):
private static class SynchronizerSessionDestroyListener implements SessionDestroyListener {
@Override
public void sessionDestroy(SessionDestroyEvent event) {
if (event.getSession() != null){
WrappedSession wrappedSession = event.getSession().getSession();
if (wrappedSession instanceof WrappedHttpSession){
WrappedHttpSession wrappedHttpSession = (WrappedHttpSession) wrappedSession;
HttpSession httpSession = wrappedHttpSession.getHttpSession();
if (httpSession != null){
try {
httpSession.invalidate();
logger.debug("Session '{}' was invalidated", httpSession.getId());
} catch (IllegalStateException e){
// do nothing, already invalidated
logger.debug("Session '{}' was already invalidated: {}", httpSession.getId(), e.getMessage());
}
} else {
logger.warn("Could not invalidate http session for vaadin session: http session is null"); // THIS IS THE BRANCH WHICH IS ACTUALLY GET EXECUTED ON 'SESSION EXPIRED' MESSAGE: event.getSession().getSession() is null!
}
} else {
logger.warn("Could not invalidate http session for vaadin session: event session is not an http session");
}
} else {
logger.warn("Could not invalidate http session for vaadin session: event session is null");
}
}
}
这里是我连接监听器:
public class X extends VaadinServlet {
// different class members
@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();
getService().addSessionDestroyListener(new SynchronizerSessionDestroyListener());
}
}
你可以发布你的'网络。 xml'看起来像那些参数?或者您是否使用注释使用参数? – JDC