Adverts
I recently got the error message "Argument Error: One or more parameters are null." when trying to load a JSF page. It confused me at first because I'd not seen this particular message before. I quickly realized what was causing the problem but it wasn't immediatly obvious why it was causing it.
SEVERE: Servlet.service() for servlet Faces Servlet threw exception java.lang.NullPointerException: Argument Error: One or more parameters are null. at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.writeText(HtmlResponseWriter.java:357) at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOption(MenuRenderer.java:581) at com.sun.faces.renderkit.html_basic.MenuRenderer.renderOptions(MenuRenderer.java:525) at com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:481) at com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:430)
The offending code was similar to the following snippet.
<h:selectOneMenu value="#{bean.intValue}">
<f:selectItem itemValue="1"/>
</h:selectOneMenu>
<f:selectItem itemValue="1"/>
</h:selectOneMenu>
The problem is that there is no itemLabel attribute. Rather than issuing a warning that itemLabel is not present error message (as it normally does with what should be a schema violation) it falls over with a NullPointer.
<h:selectOneMenu value="#{bean.intValue}">
<f:selectItem itemValue="1" itemLabel="1"/>
</h:selectOneMenu>
<f:selectItem itemValue="1" itemLabel="1"/>
</h:selectOneMenu>
The reason I'd not seen this message before is because I haven't directly specified the selection items in the page before.