[英]Hitting java.lang.IllegalStateException: null when call setAttribute() in HttpSession
Good day, 美好的一天,
The following is my java code: 以下是我的Java代码:
Map< String, Account > accountMap = result.getAccountsMap( );
if ( accountMap != null )
command.getSession( ).setAttribute( Constants.OA, accountMap );
And then on and off it will hitting IllegalStateException
since today morning: 从今天早上开始,它会
IllegalStateException
触发IllegalStateException
:
java.lang.IllegalStateException: null at com.ibm.ws.session.http.HttpSessionImpl.setAttribute(HttpSessionImpl.java:248) ~[com.ibm.ws.webcontainer.jar:na] at com.ibm.ws.session.SessionData.putSessionValue(SessionData.java:293) ~[com.ibm.ws.webcontainer.jar:na] at com.ibm.ws.session.SessionData.setAttribute(SessionData.java:217) ~[com.ibm.ws.webcontainer.jar:na] at com.ibm.ws.session.HttpSessionFacade.setAttribute(HttpSessionFacade.java:169) ~[com.ibm.ws.webcontainer.jar:na]
java.lang.IllegalStateException:在com.ibm.ws.session.http.HttpSessionImpl.setAttribute(HttpSessionImpl.java:248)处为null [在com.ibm.ws.session处为[com.ibm.ws.webcontainer.jar:na] .SessionData.putSessionValue(SessionData.java:293)〜[com.ibm.ws.webcontainer.jar:na]在com.ibm.ws.session.SessionData.setAttribute(SessionData.java:217)〜[com.ibm。 ws.webcontainer.jar:na]在com.ibm.ws.session.HttpSessionFacade.setAttribute(HttpSessionFacade.java:169)〜[com.ibm.ws.webcontainer.jar:na]
I tried to google about this, but its seems like a very common exception, and I have no idea how/where should I continue to troubleshoot. 我曾尝试在Google上进行搜索,但是这似乎是一个非常普遍的例外,而且我不知道应该如何/在何处继续进行故障排除。
This application is running on WAS 8.5.5. 该应用程序在WAS 8.5.5上运行。
Can anyone advise me on this? 有人可以建议我吗?
I would guess that the session is invalid at this point. 我想这届会议是无效的。 Can you add a check to
isRequestedSessionIdValid()
? 您可以向
isRequestedSessionIdValid()
添加支票吗? The fact that you're pulling it from a command
object, rather than from an HttpServletRequest
directly, means it could easily be an old, invalidated one. 您是从
command
对象中而不是直接从HttpServletRequest
拉出它,这意味着它很容易成为旧的,失效的。
That is correct, this was due to the method is called on an invalidated session: 没错,这是由于在无效会话上调用了该方法:
https://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSession.html#setAttribute(java.lang.String,%20java.lang.Object) https://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpSession.html#setAttribute(java.lang.String,%20java.lang.Object)
HttpServletRequest.getSession(false) should also returns null at that point. HttpServletRequest.getSession(false)那时也应该返回null。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.