CAS-ERR Cannot create a session after the response has been committed


現象:

當cas 登錄人數較少時候沒有錯誤,但是用戶過多時候出現下列err
May-2016 18:09:11.932 SEVERE [http-nio-8080-exec-52] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [cas] in context with path [/dlcas-server] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: Cannot create a session after the response has been committed] with root cause
 java.lang.IllegalStateException: Cannot create a session after the response has been committed
    at org.apache.catalina.connector.Request.doGetSession(Request.java:2935)
    at org.apache.catalina.connector.Request.getSession(Request.java:2305)
    at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:895)
    at org.springframework.webflow.context.servlet.HttpSessionMap.getMutex(HttpSessionMap.java:98)
    at org.springframework.webflow.core.collection.LocalSharedAttributeMap.getMutex(LocalSharedAttributeMap.java:39)
    at org.springframework.webflow.conversation.impl.ContainedConversation.unlock(ContainedConversation.java:108)
    at org.springframework.webflow.execution.repository.support.ConversationBackedFlowExecutionLock.unlock(ConversationBackedFlowExecutionLock.java:55)
    at 
    …………

解決方法:

cas-servlet.xml 配置文件

<bean id="terminateWebSessionListener" class="org.jasig.cas.web.flow.TerminateWebSessionListener"
p:timeToDieInSeconds="這邊調大點,默認是2" />

原理

參考 http://www.mytju.com/classcode/news_readNews.asp?newsID=504

發現重新設置了SessionID,正常登錄時則不會設置。

懷疑是Session不存在了,導致后台重新創建Session,重新返回了login頁面。

找到org.jasig.cas.web.flow下的TerminateWebSessionListener.java,
這個類監聽sessionStarted和sessionEnded事件,

加log后執行,

發現,訪問login頁面時是session start,登錄成功后是session end,

也就是說,登錄動作執行后這個session就被咔嚓掉了~~~

喀嚓掉,是使用
webSession.setMaxInactiveInterval(this.timeToDieInSeconds);實現的。

默認值是2,也就是兩秒
private int timeToDieInSeconds = 2;

執行logout時,只是讓TGC無效,並沒有重新創建Session。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM