Bug 15989 - NPE using message tag with arguments
Summary: NPE using message tag with arguments
Status: CLOSED DUPLICATE of bug 15840
Alias: None
Product: Taglibs
Classification: Unclassified
Component: I18N Taglib (show other bugs)
Version: 1.1
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-11 07:38 UTC by Dietmar Schinnerl
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dietmar Schinnerl 2003-01-11 07:38:43 UTC
Dear Jakarta-Team,

I've a small problem with the i18n taglib. If I use the message tag with
arguments (example below) I get a NullPointerException (NPE). (Environment:
Linux, Java 1.4.1_01, JBoss 3.0.4/Jetty)

However if I change line 268 of the MessageTag class (change shown below)
everything works fine (the NPE doesn't occur anymore). To me the change makes
sense, but maybe it breaks something which I'm not aware of.

If I can be of any help, please let me know.

Best regards,
Dietmar

---- JSP snippet ----

[...]
<i18n:bundle i18n="bundle" baseName="com.sony.emo2.backoffice.Texts"
localeRef="<%= com.sony.framework.command.BaseCommand.LOCALE %>" />
[...]
            <%  
            if (pageTitle != null) {
            %>
              <h1><i18n:message key="<%= pageTitle %>" /></h1>

              <%
               Object[] args = new Object[] { "abcdef" };
              %>
              <i18n:message bundleRef="bundle" key="<%= pageTitle %>" args="<%=
args %>" />
            <%
            }
            %>
[...]

---- log4j snippet ----

[...]
2003-01-11 08:17:55,646 WARN  [org.jboss.jbossweb] (SocketListener-1:) WARNING:
Exception for /emo2bo/command.jsp?cmd=login
java.lang.NullPointerException
        at org.apache.taglibs.i18n.MessageTag.doEndTag(MessageTag.java:268)
        at org.apache.jsp.menu$jsp._jspService(menu$jsp.java:563)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
[...]

---- diff ----

[dietmar@wd1w i18n]$ cvs diff -u src/org/apache/taglibs/i18n/MessageTag.java 
Index: src/org/apache/taglibs/i18n/MessageTag.java
===================================================================
RCS file:
/home/cvspublic/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/MessageTag.java,v
retrieving revision 1.5
diff -u -r1.5 MessageTag.java
--- src/org/apache/taglibs/i18n/MessageTag.java 17 Dec 2002 04:18:59 -0000      1.5
+++ src/org/apache/taglibs/i18n/MessageTag.java 11 Jan 2003 07:29:28 -0000
@@ -265,7 +265,7 @@
             // perform parameter substitutions
             if ( _value != null && _arguments != null && _arguments.size() > 0) {
                 // reformat the value as specified
-                _messageFormat.setLocale(_bundle.getLocale());
+                _messageFormat.setLocale(getBundle().getLocale());
                 _messageFormat.applyPattern(_value);
                 _value = _messageFormat.format(_arguments.toArray());
             }
Comment 1 Glenn Nielsen 2003-01-11 14:44:40 UTC

*** This bug has been marked as a duplicate of 15840 ***