[jboss-user] [JBoss Portal] - Null Pointer Exception with JSTL format tag

jupallis do-not-reply at jboss.com
Mon Oct 6 14:29:13 EDT 2008


Portal: JBoss 2.6.6 GA with JBoss AS 4.2.3. 

NPE while trying to use the JSTL fmt:message tag. 


  | Please find the stack trace below:
  | 18:58:46,984 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception java.lang.NullPointerException
  |         at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.findMatch(BundleSupport.java:250)
  |         at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.getLocalizationContext(BundleSupport.java:186)
  |         at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.doStartTag(BundleSupport.java:95)
  |         at org.apache.jsp.layouts.autodesk._2column_jsp._jspx_meth_fmt_005fbundle_005f0(_2column_jsp.java:563)
  |         at org.apache.jsp.layouts.autodesk._2column_jsp._jspService(_2column_jsp.java:180)
  |         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  |         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
  |         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)
  |         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 

When we look at the code for the BundleSupport.findMatch()


  | 243     private static LocalizationContext findMatch(PageContext  pageContext,
  | 244                          String  basename) {
  | 245     LocalizationContext locCtxt = null;
  | 246     
  | 247     // Determine locale from client's browser settings.
  | 248 
  | 249     for (Enumeration  enum_ = Util.getRequestLocales((HttpServletRequest )pageContext.getRequest());
  | 250          enum_.hasMoreElements(); ) {   //   <-- Line no 250.
  | 251         Locale  pref = (Locale ) enum_.nextElement();
  | 252         ResourceBundle  match = findMatch(basename, pref);
  | 

Enumeration enum_ is being returned as null as part of the method call Util.getRequestLocales(). 

if we look at the code for Util.getRequestLocales()

  | 280         Enumeration  values = request.getHeaders("accept-language");
  | 281         if (values.hasMoreElements()) {
  | 282             // At least one "accept-language". Simply return
  | 283 		// the enumeration returned by request.getLocales().
  | 284 		// System.out.println("At least one accept-language");
  | 285 		return request.getLocales();
  | 286         } else {
  | 287             // No header for "accept-language". Simply return
  | 288 		// the empty enumeration.
  | 289 		// System.out.println("No accept-language");
  | 290 		return values;
  | 
In the above code though the NPE problem at Ln.no 280 has been fixed still the reqeust.getLocales() is returning null and the JSTL tag is ending up with the NPE.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4180637#4180637

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4180637



More information about the jboss-user mailing list