public class SessionListener implements HttpSessionListener{
private SessionUtils context = SessionUtils.getSessionContext();
@Override
public void sessionDestroyed(HttpSessionEvent e) {
System.out.println("session过期操作----------->>>>>>>>>>>>");
context.delSession(e.getSession());//只是处理session超时的情况
}
}
//删除
public synchronized void delSession(HttpSession session) {
if(session!= null){
session.invalidate();
}
}
undertow配置
undertow.session.timeout=180
undertow.session.hotSwap=true
每次执行到 session.invalidate() 都会报错:
Exception in thread "XNIO-2 task-1" java.lang.RuntimeException: java.lang.IllegalStateException: UT000021: Session already invalidated
at io.undertow.servlet.core.SessionListenerBridge.sessionDestroyed(SessionListenerBridge.java:75)
at io.undertow.server.session.SessionListeners.sessionDestroyed(SessionListeners.java:61)
at io.undertow.server.session.InMemorySessionManager$SessionImpl.invalidate(InMemorySessionManager.java:586)
at io.undertow.server.session.InMemorySessionManager$SessionImpl$2$1.run(InMemorySessionManager.java:393)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: UT000021: Session already invalidated
at io.undertow.server.session.InMemorySessionManager$SessionImpl.invalidate(InMemorySessionManager.java:578)
at io.undertow.server.session.InMemorySessionManager$SessionImpl.invalidate(InMemorySessionManager.java:560)
at io.undertow.servlet.spec.HttpSessionImpl.invalidate(HttpSessionImpl.java:195)
at com.richfit.web.util.SessionUtils.delSession(SessionUtils.java:86)
at com.richfit.web.listener.SessionListener.sessionDestroyed(SessionListener.java:15)
at io.undertow.servlet.core.ApplicationListeners.sessionDestroyed(ApplicationListeners.java:328)
at io.undertow.servlet.core.SessionListenerBridge.doDestroy(SessionListenerBridge.java:98)
at io.undertow.servlet.core.SessionListenerBridge.access$000(SessionListenerBridge.java:41)
at io.undertow.servlet.core.SessionListenerBridge$1.call(SessionListenerBridge.java:54)
at io.undertow.servlet.core.SessionListenerBridge$1.call(SessionListenerBridge.java:51)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at io.undertow.servlet.core.SessionListenerBridge.sessionDestroyed(SessionListenerBridge.java:73)
... 6 more
不知道哪里出问题了 应该怎么改
jfinal 4.5 jfinal-undertow 1.9