Web UI Framework

JSF troubleshoot

Updated: October 16, 2020

Although they are not all specific to Nuxeo framework, here are some troubleshooting issues that can be encountered with JSF.

Some of this content is outdated and needs to be reviewed.

NullPointerException? when rendering a page

If you have a stack trace that looks like:

java.lang.NullPointerException
        at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormRenderer.encodeEnd(FormRenderer.java:210)
        at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:211)
        at org.apache.myfaces.trinidadinternal.renderkit.htmlBasic.HtmlFormRenderer.encodeEnd(HtmlFormRenderer.java:63)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)

Then you probably have a <h:form> tag inside another <h:form> tag, and this is not allowed.

My action is not called when clicking on a button

If an action listener is not called when clicking on a form button, then you probably have conversion or validation errors on the page. Add a <h:messages /> tag to your page to get more details on the actual problem.

Also make sure you don't have any <h:form> tag inside another <h:form> tag.

My file is not uploaded correctly although other fields are set

Make sure your <h:form> tag accepts multipart content: <h:form enctype="multipart/form-data">.

My ajax action does not work

There could be lots of reasons for this to happen. The easiest way to find the cause is to add a <a4j:log /> tag to your xhtml page, and then open it using CTRL+SHIFT+l. You'll get ajax debug logs in a popup window and hopefully will understand what is the problem.

Also make sure you have the right namespace: xmlns:a4j="https://ajax4jsf.dev.java.net/ajax".

My variable is not resolved correctly

A lot of different causes could explain with a variable is not resolved properly, but here are some recommandations to avoid known problems.

When exposing a variable for EL resolution, note that there are some reserved keywords. For instance in tags like:

<nxu:dataList var="action" value="#{actions}">
  ...
</nxu:dataList>

or

<nxu:inputList model="model" value="#{myList}">
...
</nxu:inputList>

or even:

<c:set var="foo" value="bar" />

The reserved keywords are: "application", "applicationScope", "cookie", "facesContext", "header", "headerValues", "initParam", "param", "paramValues", "request", "requestScope", "session", "sessionScope", and "view".

All values in the EL context for one of these keywords will resolve to request information instead of mapping your value.

ClassCastException on h:selectManyCheckbox (or such) jsf tag

If you see the following stacktrace:

Caused by: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.util.Collection
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:356)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:128)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:314)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
    at javax.faces.component.UIInput.validate(UIInput.java:976)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processComponent(UIValueHolder.java:258)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processFacetsAndChildren(UIValueHolder.java:237)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processFacetsAndChildrenWithVariable(UIValueHolder.java:245)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processValidators(UIValueHolder.java:184)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    ... 66 more

add collectionType="java.util.ArrayList"

    <h:selectManyCheckbox id="#{widget.id}_checkbox" value="#{field}"
        layout="pageDirection" collectionType="java.util.ArrayList">
        <nxu:selectItems
            value="#{aBean.getValues()}"
            var="item" itemValue="#{item.id}"
            itemLabel="#{item.label}"/>
    </h:selectManyCheckbox>

 

IE throws errors like 'Out of memory at line 3156'

This is probably due to some forgotten a4j:log tag on one of your xhtml pages: IE does not play well with this tag from the RichFaces ajax library, and useful for debugging. It usually happens when entering values on a form, and it may not happen on every page holding the tag.


 

Although they are not all specific to Nuxeo framework, here are some troubleshooting issues that can be encountered with JSF.

Some of this content is outdated and needs to be reviewed.

NullPointerException? when rendering a page

If you have a stack trace that looks like:

java.lang.NullPointerException
        at org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.FormRenderer.encodeEnd(FormRenderer.java:210)
        at org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:211)
        at org.apache.myfaces.trinidadinternal.renderkit.htmlBasic.HtmlFormRenderer.encodeEnd(HtmlFormRenderer.java:63)
        at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:896)
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)

Then you probably have a <h:form> tag inside another <h:form> tag, and this is not allowed.

My action is not called when clicking on a button

If an action listener is not called when clicking on a form button, then you probably have conversion or validation errors on the page. Add a <h:messages /> tag to your page to get more details on the actual problem.

Also make sure you don't have any <h:form> tag inside another <h:form> tag.

My file is not uploaded correctly although other fields are set

Make sure your <h:form> tag accepts multipart content: <h:form enctype="multipart/form-data">.

My ajax action does not work

There could be lots of reasons for this to happen. The easiest way to find the cause is to add a <a4j:log /> tag to your xhtml page, and then open it using CTRL+SHIFT+l. You'll get ajax debug logs in a popup window and hopefully will understand what is the problem.

Also make sure you have the right namespace: xmlns:a4j="https://ajax4jsf.dev.java.net/ajax".

My variable is not resolved correctly

A lot of different causes could explain with a variable is not resolved properly, but here are some recommandations to avoid known problems.

When exposing a variable for EL resolution, note that there are some reserved keywords. For instance in tags like:

<nxu:dataList var="action" value="#{actions}">
  ...
</nxu:dataList>

or

<nxu:inputList model="model" value="#{myList}">
...
</nxu:inputList>

or even:

<c:set var="foo" value="bar" />

The reserved keywords are: "application", "applicationScope", "cookie", "facesContext", "header", "headerValues", "initParam", "param", "paramValues", "request", "requestScope", "session", "sessionScope", and "view".

All values in the EL context for one of these keywords will resolve to request information instead of mapping your value.

ClassCastException on h:selectManyCheckbox (or such) jsf tag

If you see the following stacktrace:

Caused by: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to java.util.Collection
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValuesForModel(MenuRenderer.java:356)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectManyValue(MenuRenderer.java:128)
    at com.sun.faces.renderkit.html_basic.MenuRenderer.getConvertedValue(MenuRenderer.java:314)
    at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1046)
    at javax.faces.component.UIInput.validate(UIInput.java:976)
    at javax.faces.component.UIInput.executeValidate(UIInput.java:1249)
    at javax.faces.component.UIInput.processValidators(UIInput.java:712)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIForm.processValidators(UIForm.java:253)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processComponent(UIValueHolder.java:258)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processFacetsAndChildren(UIValueHolder.java:237)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processFacetsAndChildrenWithVariable(UIValueHolder.java:245)
    at org.nuxeo.ecm.platform.ui.web.component.holder.UIValueHolder.processValidators(UIValueHolder.java:184)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1258)
    at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:646)
    ... 66 more

add collectionType="java.util.ArrayList" to the jsf tag causing the error:

    <h:selectManyCheckbox id="#{widget.id}_checkbox" value="#{field}"
        layout="pageDirection" collectionType="java.util.ArrayList">
        <nxu:selectItems
            value="#{aBean.getValues()}"
            var="item" itemValue="#{item.id}"
            itemLabel="#{item.label}"/>
    </h:selectManyCheckbox>

 

IE throws errors like 'Out of memory at line 3156'

This is probably due to some forgotten a4j:log tag on one of your xhtml pages: IE does not play well with this tag from the RichFaces ajax library, and useful for debugging. It usually happens when entering values on a form, and it may not happen on every page holding the tag.