NPE using JSTL format
peterj Aug 8, 2006 7:44 PMTrying to use the format taglib in a JSP within a portlet. But use of f:message leads to:
2006-08-08 16:27:05,734 ERROR [org.jboss.portal.core.command.ControllerCommand] Rendering portlet window default.default.ImagePortletWindow triggered the following error : ... Caused by: java.lang.NullPointerException at org.apache.taglibs.standard.tag.common.core.Util.getRequestLocales(Util.java:281) at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.findMatch(BundleSupport.java:249) at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.getLocalizationContext(BundleSupport.java:186) at org.apache.taglibs.standard.tag.common.fmt.BundleSupport.getLocalizationContext(BundleSupport.java:137) at org.apache.taglibs.standard.tag.common.fmt.MessageSupport.doEndTag(MessageSupport.java:153) at org.apache.jsp.WEB_002dINF.jsp.edit_jsp._jspx_meth_f_message_0(edit_jsp.java:133) at org.apache.jsp.WEB_002dINF.jsp.edit_jsp._jspService(edit_jsp.java:70) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) . . .
Looking at the Util class, I see:
public static Enumeration getRequestLocales(HttpServletRequest request) {
Enumeration values = request.getHeaders("accept-language");
if (values.hasMoreElements()) { //<== line 281
// At least one "accept-language". Simply return
// the enumeration returned by request.getLocales().
// System.out.println("At least one accept-language");
return request.getLocales();
} else {
// No header for "accept-language". Simply return
// the empty enumeration.
// System.out.println("No accept-language");
return values;
}
}It appears that the portal is stripping the language sent by the browser, and thus returning a null when asked for "accept-language". I even added a supported-locale entry in my portal.xml file, but still get the same NPE.
Does anyone have a JSP using the format JSTL and it works?
JBoss AS 4.0.4.GA, JBoss Portal 2.4.0CR3, Sun JDK 1.5.0_06