Search code examples
jsfjsf-2.2mojarrapassthrough-attributes

java.lang.NullPointerException: at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.getAttributeValue


I'm trying to use the new passthrough attribute feature in my web application, however i'm having problems with nullable attributes. This is the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 

"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" 
      xmlns:util="http://xmlns.jcp.org/jsf/composite/util"
      xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
...
<p:outputPanel  pt:example="#{mybean.nullableAttribute}"  >
...
</p:outputPanel>

I'm getting the exception:

ERROR  javax.enterprise.resource.webcontainer.jsf.application 12:01:09.205 [http-listener-1(3)]  - Error Rendering View[/index.xhtml]
java.lang.NullPointerException: null
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.getAttributeValue(HtmlResponseWriter.java:1215) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.flushAttributes(HtmlResponseWriter.java:1175) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.closeStartIfNecessary(HtmlResponseWriter.java:1117) ~[javax.faces-2.2.6.jar:2.2.6]
    at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startElement(HtmlResponseWriter.java:646) ~[javax.faces-2.2.6.jar:2.2.6]
    at org.primefaces.component.growl.GrowlRenderer.encodeEnd(GrowlRenderer.java:38) ~[primefaces-4.0.jar:4.0]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) ~[javax.faces-2.2.6.jar:2.2.6]
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:74) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeMarkup(OutputPanelRenderer.java:64) ~[primefaces-4.0.jar:4.0]
    at org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:40) ~[primefaces-4.0.jar:4.0]
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1864) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1857) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) ~[javax.faces-2.2.6.jar:2.2.6]
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1860) ~[javax.faces-2.2.6.jar:2.2.6]

When the attribute is null. It does work when it's not null. I have tried with mojarra 2.2.0 and 2.2.6 (I'm on glassfish 4.0)

Any ideas?

Thanks!


Solution

  • This bug was reported as issue 3208 is fixed in Mojarra 2.2.7.

    So, upgrading to at least that version should do. Currently, it's already at 2.2.8.