简体   繁体   中英

Possibly corrupted java.util.Locale causes NullPointerException

It all started when I got a NullpointerException in my JSP file. The line causing it only had a Struts 1.3 tag: <html:html>

The root cause from the stack trace was this:

java.lang.NullPointerException
java.util.Locale.toString(Unknown Source)
org.apache.el.lang.ELSupport.coerceToString(ELSupport.java:377)
org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:407)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:188)
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:938)
org.apache.jsp.search_jsp._jspService(search_jsp.java:193)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.servlets.ShowAllJobsServ.doGet(ShowAllJobsServ.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)

I started my research and found out that Struts retrieves a Locale object from session, in order to support i82n features. Then I thought: Maybe there is no Locale in session, after all I'm not using that feature yet. I'll test the object for null. So I wrote:

${empty sessionScope["org.apache.struts.action.LOCALE"]}

and it printed false .

I called other methods from this same object, including getCountry, getLanguage and hashCode. All resulted in NullPointerException. The only one I could call successfully was getClass. I am now very confused.

My only guess is that somehow the Locale object is not being deserialized correctly. I must say I am using MemcachedSessionManager to store Tomcat sessions in a Memcached server, succesfully storing basic beans and even collections pulled from Hibernate.

And if that wasn't strange enough, it works on my machine™ and only causes this mess when I deploy my application on Windows Azure.

Any clue? Does it even make any sense?

Talk about dumb mistakes. My deploy on Windows Azure was using JRE 7 and I use JRE 6 on my local machine. I Guess MemcachedSessionManager, Tomcat 6 and Java 7 don't work too well together :/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM