Details

Description

I get the following NPE for a tr:messages tag using Trinidad-1.2.3:

java.lang.NullPointerException
at org.apache.catalina.connector.CoyoteWriter.write(CoyoteWriter.java:171)
at org.apache.myfaces.trinidadinternal.io.HtmlResponseWriter.write(HtmlResponseWriter.java:341)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at org.apache.myfaces.trinidadinternal.io.IndentingResponseWriter.write(IndentingResponseWriter.java:152)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at org.apache.myfaces.trinidadinternal.io.DebugResponseWriter.write(DebugResponseWriter.java:124)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at com.sun.facelets.StateWriter.write(StateWriter.java:116)
at org.apache.myfaces.trinidadinternal.io.HtmlResponseWriter.write(HtmlResponseWriter.java:341)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at org.apache.myfaces.trinidadinternal.io.IndentingResponseWriter.write(IndentingResponseWriter.java:152)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at org.apache.myfaces.trinidadinternal.io.DebugResponseWriter.write(DebugResponseWriter.java:124)
at org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator.write(ResponseWriterDecorator.java:162)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.MessageBoxRenderer._renderMessageAnchor(MessageBoxRenderer.java:305)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.MessageBoxRenderer._renderComponentMessages(MessageBoxRenderer.java:263)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.MessageBoxRenderer._renderContent(MessageBoxRenderer.java:204)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.MessageBoxRenderer$BoxRenderer.renderBody(MessageBoxRenderer.java:453)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelBoxRenderer._renderMiddleRow(PanelBoxRenderer.java:267)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PanelBoxRenderer.encodeAll(PanelBoxRenderer.java:115)
at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.MessageBoxRenderer.encodeAll(MessageBoxRenderer.java:142)
at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:220)
at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:749)

A validator throws a ValidatorException with a FaceMessage inside.

All resource bundles are defined in the faces-config.xml file if that makes a difference - e.g. no f:loadBundle's.

Activity

Can also be reproduced with: Converter in <tr:inputText> throwing a ConverterException with a FaceMessage inside.

Caused by: FacesMessageWrapper constructed with a null label. The null label is ultimately given to the ResponseWriter which triggers the NPE. I dont know if FacesMessageWrapper should not be constructed with a null label or if MessageBoxRenderer should not render the label if its null. So I can't provide a patch.

Work around: Use org.apache.myfaces.trinidad.util.LabeledFacesMessage instead of javax.faces.application.FacesMessage in your validator / converter with message.setLabel("") .

Thorsten Guenther
added a comment - 08/Nov/07 23:13 Can also be reproduced with: Converter in <tr:inputText> throwing a ConverterException with a FaceMessage inside.
Caused by: FacesMessageWrapper constructed with a null label. The null label is ultimately given to the ResponseWriter which triggers the NPE. I dont know if FacesMessageWrapper should not be constructed with a null label or if MessageBoxRenderer should not render the label if its null. So I can't provide a patch.
Work around: Use org.apache.myfaces.trinidad.util.LabeledFacesMessage instead of javax.faces.application.FacesMessage in your validator / converter with message.setLabel("") .

Jesper Pedersen
added a comment - 16/Nov/07 09:10 The following patch is against the 1.2.4-branch and uses summary if no label is specified.
It fixes the NPE, but the question is if it is the correct fix in the long run.