You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Paul Spencer <pa...@apache.org> on 2014/07/04 06:08:12 UTC

Getting NPE when flowscope value evaluates to null.

MyFaces 2.2.3 &  2.2.4
jetty-maven-plugin:8.1.15.v20140411

Getting NPE when Flow Scope parameter evaluates to null.

If no value is entered for firstName before “continue” on  campaigns/campaigns.xhtml is clicked, the NPE below thrown. Otherwise the page2.xhtml is displayed as expected.

***
* campaigns/campaigns.xhtml
***
	<h:outputLabel for="firstName" value="First Name" />
	<h:inputText id="firstName" value="#{flowScope.firstName}" maxlength="10" />
	<h:commandButton value=“Continue” action=“page2” />

***
* campaigns/page2.xhtml
***
	<h:commandButton value=“Exit" action="campaigns-return" />
	<h:outputLabel for="firstName" value="First Name" />
	<h:inputText id=“firstName" value="#{flowScope.firstName}" maxlength="10" />

***
* Error displayed when page2.xhtml is returned and firstName is null
***
> java.lang.NullPointerException
> 
> viewId=/campaigns/campaigns.xhtml
> location=/Users/paul/Documents/workspace-4.3.2/VenderRollsImporterMockUp/src/main/webapp/campaigns/campaigns.xhtml
> phaseId=UPDATE_MODEL_VALUES(4)
> 
> Caused by:
> java.lang.NullPointerException - java.lang.NullPointerException
> at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
> <HtmlInputText class="class javax.faces.component.html.HtmlInputText” clientId="j_id_s:firstName" disabled="false" id="firstName" immediate="false" inView="true" localValueSet="true" maxlength="10" readonly="false" rendered="true" required="false" size="-2147483648" transient="false" valid="false" value="#{flowScope.firstName}" location="/campaigns/campaigns.xhtml at line 76 and column 82"/> - State size:246 bytes

***
* Scopes Value
***
> Request Parameters
> Name	Value
> j_id_s:firstName	
> j_id_s:j_id_x	Continue
> j_id_s_SUBMIT	1
> jfwid	-lbh0f813a


Is this normal?

Paul Spencer

Re: Getting NPE when flowscope value evaluates to null.

Posted by Leonardo Uribe <lu...@gmail.com>.
Hi

I tried to set the null value with MyFaces 2.2.4 and it works as expected.

But trying with Mojarra 2.2.7 I get this:

javax.faces.component.UpdateModelException: java.lang.NullPointerException
at javax.faces.component.UIInput.updateModel(UIInput.java:866)
at javax.faces.component.UIInput.processUpdates(UIInput.java:749)
at javax.faces.component.UIForm.processUpdates(UIForm.java:281)

Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
at javax.el.MapELResolver.setValue(MapELResolver.java:265)
at com.sun.faces.el.DemuxCompositeELResolver._setValue(DemuxCompositeELResolver.java:255)
at com.sun.faces.el.DemuxCompositeELResolver.setValue(DemuxCompositeELResolver.java:281)
at com.sun.el.parser.AstValue.setValue(AstValue.java:201)
at com.sun.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:291)
at org.apache.webbeans.el22.WrappedValueExpression.setValue(WrappedValueExpression.java:95)
at com.sun.faces.facelets.el.TagValueExpression.setValue(TagValueExpression.java:131)
at javax.faces.component.UIInput.updateModel(UIInput.java:832)
... 34 more

Take a look your classpath, probably something is not right.

regards,

Leonardo

2014-07-03 23:08 GMT-05:00 Paul Spencer <pa...@apache.org>:
> MyFaces 2.2.3 &  2.2.4
> jetty-maven-plugin:8.1.15.v20140411
>
> Getting NPE when Flow Scope parameter evaluates to null.
>
> If no value is entered for firstName before “continue” on  campaigns/campaigns.xhtml is clicked, the NPE below thrown. Otherwise the page2.xhtml is displayed as expected.
>
> ***
> * campaigns/campaigns.xhtml
> ***
>         <h:outputLabel for="firstName" value="First Name" />
>         <h:inputText id="firstName" value="#{flowScope.firstName}" maxlength="10" />
>         <h:commandButton value=“Continue” action=“page2” />
>
> ***
> * campaigns/page2.xhtml
> ***
>         <h:commandButton value=“Exit" action="campaigns-return" />
>         <h:outputLabel for="firstName" value="First Name" />
>         <h:inputText id=“firstName" value="#{flowScope.firstName}" maxlength="10" />
>
> ***
> * Error displayed when page2.xhtml is returned and firstName is null
> ***
>> java.lang.NullPointerException
>>
>> viewId=/campaigns/campaigns.xhtml
>> location=/Users/paul/Documents/workspace-4.3.2/VenderRollsImporterMockUp/src/main/webapp/campaigns/campaigns.xhtml
>> phaseId=UPDATE_MODEL_VALUES(4)
>>
>> Caused by:
>> java.lang.NullPointerException - java.lang.NullPointerException
>> at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
>> <HtmlInputText class="class javax.faces.component.html.HtmlInputText” clientId="j_id_s:firstName" disabled="false" id="firstName" immediate="false" inView="true" localValueSet="true" maxlength="10" readonly="false" rendered="true" required="false" size="-2147483648" transient="false" valid="false" value="#{flowScope.firstName}" location="/campaigns/campaigns.xhtml at line 76 and column 82"/> - State size:246 bytes
>
> ***
> * Scopes Value
> ***
>> Request Parameters
>> Name  Value
>> j_id_s:firstName
>> j_id_s:j_id_x Continue
>> j_id_s_SUBMIT 1
>> jfwid -lbh0f813a
>
>
> Is this normal?
>
> Paul Spencer