Today, colleagues in the local construction of the Web application development environment, the login has been reported null pointer exception. After viewing the log, it was found that the null value was obtained when reading the properties in the session. After reviewing the code, no exceptions were found. Some places use the Response.Redirect () method, but do not get the value in the session. This article will record how the issue is resolved.
First, the development environment: WebLogic, MyEclipse.
Second, the problem-solving ideas:
1, the confirmation is not because of the code causes, I suspect is the session re-creation reason. To verify this conclusion, I printed the value of the session ID to the console in the code. The location is two places: one is when the login information is placed in the session, one is to visit the session in the login information. After viewing the output information, it was found that the two IDs were completely different, indicating that the session was recreated.
2, the session is constantly re-created, according to the principle of the session, you can know that the server did not get valid Jsessionid information from the request header. So consider disabling cookies locally, and confirm that cookies are not disabled locally. Blocked
3, the suspect session was invalidated. Created a session of the listener class, did not find the session failure action.
4, later view the WebLogic configuration file, found that the cookie path is set:
<weblogic-web-app> <session-descriptor> <session-param> <param-name> cookiepath</param-name> <param-name>/cw/</param-name> </session-param> </session-descriptor></weblogic-web-app>
Change the path to/cw/because there is no local directory, so the cookie file is not created at all. Therefore, after the login information is placed in the session, Jsessionid should be placed in the cookie for the next use, but because the path cannot be found, causing the cookie file is not created correctly, and, after redirection, the request also cannot find the cookie file, Therefore, there is no jsessionid information, so the server can not find any session information from the request, only re-create a session. This causes the problem to be mentioned at the beginning of this article.
This problem can be analogous to other web containers, such as Tomcat.
Web apps constantly create new sessions