简体   繁体   English

击中java.lang.IllegalStateException:在HttpSession中调用setAttribute()时为null

[英]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.

相关问题 java.lang.IllegalStateException:目标主机为null - java.lang.IllegalStateException: Target host is null java.lang.IllegalStateException:带有迭代器的null - java.lang.IllegalStateException: null with iterator java.lang.IllegalStateException:[TextView]不能为null - java.lang.IllegalStateException: [TextView] must not be null 呼叫记录失败,并出现java.lang.IllegalStateException - Call Recording failed with java.lang.IllegalStateException java.lang.IllegalStateException - java.lang.IllegalStateException 插入数据库时​​出现java.lang.IllegalStateException - java.lang.IllegalStateException when insert into database 创建BufferStrategy时出现java.lang.IllegalStateException - java.lang.IllegalStateException when creating BufferStrategy java.lang.IllegalStateException:使用 WebSecurityConfigurerAdapter 时 - java.lang.IllegalStateException: When using WebSecurityConfigurerAdapter 异常后,Quartz Scheduler不工作[java.lang.IllegalStateException:HttpSession无效] - Quartz scheduler Not Working after exception [java.lang.IllegalStateException: HttpSession is invalid] java.lang.IllegalStateException目标主机不能为null连接到数据库 - java.lang.IllegalStateException Target host must not be null connecting to database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM