You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by my...@arcor.de on 2010/06/29 15:15:11 UTC

ExtVal: NullPointer during EL resolving for custom component

Hi,

the following NPE occured using Myfaces ExtVal:

java.lang.NullPointerException
	at javax.faces.component.UIComponent.getValueExpression(UIComponent.java:338)
	at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.getExpression(CompositeComponentAttributesELResolver.java:314)
	at org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getCompositeComponentExpression(ExtValELResolver.java:277)
	at org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(DefaultELHelper.java:169)
	at org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.java:77)
	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.getPropertyInformation(AbstractValidationInterceptor.java:176)
	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.processAfterValidation(AbstractValidationInterceptor.java:166)
	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:153)
	at org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.getConvertedValue(ExtValRendererWrapper.java:369)
	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
	at javax.faces.component.UIInput.validate(UIInput.java:934)
	at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
	at javax.faces.component.UIInput.processValidators(UIInput.java:691)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIForm.processValidators(UIForm.java:243)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
	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:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)


I used the following code:

Page:

          <ui:composition template="/resources/templates/test-template.xhtml">
	
		<ui:define name="test-workspace">
			
			<ui:remove> 
				a) works <parts-test:nestedCC myValue="#{personBean.person}"/>
			        b) works <parts-test:nestedCC myValue="#{personBean.person.adresse}"/>
			</ui:remove> 
			
			c) NPE!!! <parts-test:nestedCC myValue="#{personBean.person.adresse.plz}"/>
			
		</ui:define>
		
	</ui:composition>

CustomComponent:

	<composite:interface>
		<composite:attribute name="myValue" required="true" />
	</composite:interface>

       <composite:implementation>
	
		<ui:remove> 
			a) works <h:inputText id="theValue" value="#{cc.attrs.myValue.adresse.plz}" />
                        b) works <h:inputText id="theValue" value="#{cc.attrs.myValue.plz}" />
		</ui:remove> 
	
		    c) NPE!!! <h:inputText id="theValue" value="#{cc.attrs.myValue}" />	

	</composite:implementation>

The code behind the scenes is:
- a managed bean "PersonBean"
- ...which refers to an object "Person" which refers to an object "Adresse" which has a string property "plz"
- for testing purposes I implemented some get/setPlz in PersonBean and Person too which provide the value stored in Adresse.plz

In case c), using a deeply nested EL expression, the NPE occurs.

In the ExtVal code I found in org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(UIComponent):

@ToDo(value = Priority.HIGH, description = "check if it works with nested composite components")

Is this TODO still an open one or is the EL expression revealing a new bug? 

-- 
WM 2010: Top News, Spielpläne, Public Viewing-Termine, E-Cards und alles, 
was der Fan sonst noch braucht, gibt´s im Sport-Channel auf arcor.de.
http://www.arcor.de/rd/footer.wm2010

Re: ExtVal: NullPointer during EL resolving for custom component

Posted by Gerhard Petracek <ge...@gmail.com>.
hi,

i've found a different solution.
if the found base object is an instance of
CompositeComponentExpressionHolder, we have to create a new ValueExpression
based on the found base object and the found property. this
new ValueExpression is used to inspect the target (again).

@leonardo:
it would be great if you have time to check the solution in combination with
myfaces-core2.

regards,
gerhard

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2010/6/30 Leonardo Uribe <lu...@gmail.com>

> Hi
>
> Thanks for the demo, it helps a lot. I tried th with myfaces and it throws
> the same exception:
>
> javax.faces.FacesException: java.lang.NullPointerException: name can not be
> null
>        at
> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)
>
>        at
> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
>        at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:169)
>        at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
>
>        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
>
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>        at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
>
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>        at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
>        at
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException: name can not be null
>        at
> javax.faces.component.UIComponent.getValueExpression(UIComponent.java:543)
>        at
> org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.getExpression(CompositeComponentELResolver.java:208)
>
>        at
> org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getCompositeComponentExpression(ExtValELResolver.java:277)
>        at
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(DefaultELHelper.java:169)
>
>        at
> org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.java:77)
>        at
> org.apache.myfaces.extensions.validator.util.ExtValUtils$1.extract(ExtValUtils.java:233)
>
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.getPropertyInformation(AbstractValidationInterceptor.java:176)
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.processAfterValidation(AbstractValidationInterceptor.java:166)
>
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:153)
>        at
> org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.getConvertedValue(ExtValRendererWrapper.java:369)
>
>        at javax.faces.component.UIInput.getConvertedValue(UIInput.java:578)
>        at javax.faces.component.UIInput.validate(UIInput.java:510)
>        at javax.faces.component.UIInput.processValidators(UIInput.java:240)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)
>
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)
>        at javax.faces.component.UIForm.processValidators(UIForm.java:137)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)
>
>        at
> javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1251)
>        at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:77)
>        at
> javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1298)
>
>        at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1207)
>        at
> javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:683)
>        at
> org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:34)
>
>        at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:149)
>
> The problem resides in how CompositeComponentELResolver works. In few
> words,
> it returns a Map that points to composite component attributes, but this
> map
> is traversed by default MapELResolver, not the same
> CompositeComponentELResolver, so ExtValELResolver wrapper does not receive
> the control before evaluate and compositeComponentExpressionBase is never
> set.
>
> The solution should be do something similar to the hack done in
> FlashELResolver. In that case, the resolver checks if the base is
> instanceof
> the map (in myfaces case CompositeComponentAttributesMapWrapper) and if so
> return the value as MapELResolver does (or in other words as
> FlashELResolver
> does).
>
> I have not tested this solution yet but I think it will work. The behavior
> proposed is not described on jsf 2.0 spec section 5.6.2.2, but I think we
> can consider it an implementation detail and create a fix on myfaces.
> Please
> create an issue on myfaces issue tracker and I'll propose a patch for this
> one.
>
> regards,
>
> Leonardo Uribe
>

Aw: Re: ExtVal: NullPointer during EL resolving for custom component

Posted by my...@arcor.de.
Hi Gerhard, hi Leonardo,

Gerhard had already taken a look at this too.

JIRA-Issue: https://issues.apache.org/jira/browse/EXTVAL-102

Tom



----- Original Nachricht ----
Von:     Leonardo Uribe <lu...@gmail.com>
An:      MyFaces Discussion <us...@myfaces.apache.org>
Datum:   30.06.2010 08:22
Betreff: Re: ExtVal: NullPointer during EL resolving for custom component

> Hi
> 
> Thanks for the demo, it helps a lot. I tried th with myfaces and it throws
> the same exception:
> 
> javax.faces.FacesException: java.lang.NullPointerException: name can not be
> null
> 	at
> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHa
> ndlerImpl.java:241)
> 
> 	at
> org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(Exception
> HandlerImpl.java:156)
> 	at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:1
> 69)
> 	at
> org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
> 
> 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
> FilterChain.java:290)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
> ain.java:206)
> 
> 	at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
> va:233)
> 	at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
> va:175)
> 	at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128
> )
> 
> 	at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102
> )
> 	at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
> :109)
> 	at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
> 
> 	at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> 	at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http
> 11Protocol.java:583)
> 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
> 
> 	at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.NullPointerException: name can not be null
> 	at
> javax.faces.component.UIComponent.getValueExpression(UIComponent.java:543)
> 	at
> org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$Composit
> eComponentAttributesMapWrapper.getExpression(CompositeComponentELResolver.jav
> a:208)
> 
> 	at
> org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getComposit
> eComponentExpression(ExtValELResolver.java:277)
> 	at
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyD
> etailsOfValueBinding(DefaultELHelper.java:169)
> 
> 	at
> org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultCompo
> nentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.java:77)
> 	at
> org.apache.myfaces.extensions.validator.util.ExtValUtils$1.extract(ExtValUti
> ls.java:233)
> 
> 	at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationI
> nterceptor.getPropertyInformation(AbstractValidationInterceptor.java:176)
> 	at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationI
> nterceptor.processAfterValidation(AbstractValidationInterceptor.java:166)
> 
> 	at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationI
> nterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:153)
> 	at
> org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper
> .getConvertedValue(ExtValRendererWrapper.java:369)
> 
> 	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:578)
> 	at javax.faces.component.UIInput.validate(UIInput.java:510)
> 	at javax.faces.component.UIInput.processValidators(UIInput.java:240)
> 	at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
> :1218)
> 
> 	at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
> :1218)
> 	at javax.faces.component.UIForm.processValidators(UIForm.java:137)
> 	at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java
> :1218)
> 
> 	at
> javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1
> 251)
> 	at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:77)
> 	at
> javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIVi
> ewRoot.java:1298)
> 
> 	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1207)
> 	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:683)
> 	at
> org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValid
> ationsExecutor.java:34)
> 
> 	at
> org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:1
> 49)
> 
> The problem resides in how CompositeComponentELResolver works. In few
> words,
> it returns a Map that points to composite component attributes, but this
> map
> is traversed by default MapELResolver, not the same
> CompositeComponentELResolver, so ExtValELResolver wrapper does not receive
> the control before evaluate and compositeComponentExpressionBase is never
> set.
> 
> The solution should be do something similar to the hack done in
> FlashELResolver. In that case, the resolver checks if the base is
> instanceof
> the map (in myfaces case CompositeComponentAttributesMapWrapper) and if so
> return the value as MapELResolver does (or in other words as
> FlashELResolver
> does).
> 
> I have not tested this solution yet but I think it will work. The behavior
> proposed is not described on jsf 2.0 spec section 5.6.2.2, but I think we
> can consider it an implementation detail and create a fix on myfaces.
> Please
> create an issue on myfaces issue tracker and I'll propose a patch for this
> one.
> 
> regards,
> 
> Leonardo Uribe
> 

-- 
Hotelbewertung: Bloß nicht die Katze im Sack kaufen bzw. den Floh auf der Matratze buchen - 
ob geschäftlich oder privat - erst das Hotel im Reise-Channel auf arcor.de checken!
http://www.arcor.de/rd/footer.hotel


Re: ExtVal: NullPointer during EL resolving for custom component

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

Thanks for the demo, it helps a lot. I tried th with myfaces and it throws
the same exception:

javax.faces.FacesException: java.lang.NullPointerException: name can not be null
	at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.wrap(ExceptionHandlerImpl.java:241)

	at org.apache.myfaces.shared_impl.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:156)
	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:169)
	at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)

	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)

	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)

	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)

	at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NullPointerException: name can not be null
	at javax.faces.component.UIComponent.getValueExpression(UIComponent.java:543)
	at org.apache.myfaces.el.unified.resolver.CompositeComponentELResolver$CompositeComponentAttributesMapWrapper.getExpression(CompositeComponentELResolver.java:208)

	at org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getCompositeComponentExpression(ExtValELResolver.java:277)
	at org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(DefaultELHelper.java:169)

	at org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.java:77)
	at org.apache.myfaces.extensions.validator.util.ExtValUtils$1.extract(ExtValUtils.java:233)

	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.getPropertyInformation(AbstractValidationInterceptor.java:176)
	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.processAfterValidation(AbstractValidationInterceptor.java:166)

	at org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:153)
	at org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.getConvertedValue(ExtValRendererWrapper.java:369)

	at javax.faces.component.UIInput.getConvertedValue(UIInput.java:578)
	at javax.faces.component.UIInput.validate(UIInput.java:510)
	at javax.faces.component.UIInput.processValidators(UIInput.java:240)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)

	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)
	at javax.faces.component.UIForm.processValidators(UIForm.java:137)
	at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1218)

	at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1251)
	at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:77)
	at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1298)

	at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1207)
	at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:683)
	at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:34)

	at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:149)

The problem resides in how CompositeComponentELResolver works. In few words,
it returns a Map that points to composite component attributes, but this map
is traversed by default MapELResolver, not the same
CompositeComponentELResolver, so ExtValELResolver wrapper does not receive
the control before evaluate and compositeComponentExpressionBase is never
set.

The solution should be do something similar to the hack done in
FlashELResolver. In that case, the resolver checks if the base is instanceof
the map (in myfaces case CompositeComponentAttributesMapWrapper) and if so
return the value as MapELResolver does (or in other words as FlashELResolver
does).

I have not tested this solution yet but I think it will work. The behavior
proposed is not described on jsf 2.0 spec section 5.6.2.2, but I think we
can consider it an implementation detail and create a fix on myfaces. Please
create an issue on myfaces issue tracker and I'll propose a patch for this
one.

regards,

Leonardo Uribe

AW: ExtVal: NullPointer during EL resolving for custom component

Posted by "Tom M." <my...@arcor.de>.
Hi Gerhard,

a demo is available as war-file:
http://www.humyo.de/10453303/TestProject.war?a=fojK9Jp2984. Just follow the
links, enter a value and press the button. 

In org.apache.myfaces.extensions.validator.core.el.ExtValELResolver:

    public ValueExpression getCompositeComponentExpression()
    {
        if(this.compositeComponentExpressionHolder != null)
        {
            return
this.compositeComponentExpressionHolder.getExpression(this.compositeComponen
tExpressionBase);
        }
        return null;
    }

this.compositeComponentExpressionBase is null which leads into the NPE.


Thanks for taking a look insight.

Tom




> -----Ursprüngliche Nachricht-----
> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> Gesendet: Dienstag, 29. Juni 2010 15:44
> An: MyFaces Discussion
> Betreff: Re: ExtVal: NullPointer during EL resolving for custom
> component
> 
> hi tom,
> 
> we have to check if it is an issue of the jsf impl. you are using.
> the todo was placed there, because there were some changes in the jsf
> implementations.
> 
> it would be nice if you can provide a link to a small demo app which
> illustrates the issue.
> (-> not everybody of the community who would like to debug the issue
> has to
> create the demo app.)
> 
> regards,
> gerhard
> 
> http://www.irian.at
> 
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
> 
> Professional Support for Apache MyFaces
> 
> 
> 
> 2010/6/29 <my...@arcor.de>
> 
> > Hi,
> >
> > the following NPE occured using Myfaces ExtVal:
> >
> > java.lang.NullPointerException
> >        at
> >
> javax.faces.component.UIComponent.getValueExpression(UIComponent.java:3
> 38)
> >        at
> >
> com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalM
> ap.getExpression(CompositeComponentAttributesELResolver.java:314)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getCom
> positeComponentExpression(ExtValELResolver.java:277)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getProp
> ertyDetailsOfValueBinding(DefaultELHelper.java:169)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.metadata.extractor.Default
> ComponentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.ja
> va:77)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValida
> tionInterceptor.getPropertyInformation(AbstractValidationInterceptor.ja
> va:176)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValida
> tionInterceptor.processAfterValidation(AbstractValidationInterceptor.ja
> va:166)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValida
> tionInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.j
> ava:153)
> >        at
> >
> org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWr
> apper.getConvertedValue(ExtValRendererWrapper.java:369)
> >        at
> > javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
> >        at javax.faces.component.UIInput.validate(UIInput.java:934)
> >        at
> javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
> >        at
> javax.faces.component.UIInput.processValidators(UIInput.java:691)
> >        at
> >
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase
> .java:1080)
> >        at
> >
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase
> .java:1080)
> >        at
> javax.faces.component.UIForm.processValidators(UIForm.java:243)
> >        at
> >
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase
> .java:1080)
> >        at
> >
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase
> .java:1080)
> >        at
> >
> javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180
> )
> >        at
> >
> com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidati
> onsPhase.java:76)
> >        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
> >        at
> > com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
> >        at
> javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
> >
> >
> > I used the following code:
> >
> > Page:
> >
> >          <ui:composition
> > template="/resources/templates/test-template.xhtml">
> >
> >                <ui:define name="test-workspace">
> >
> >                        <ui:remove>
> >                                a) works <parts-test:nestedCC
> > myValue="#{personBean.person}"/>
> >                                b) works <parts-test:nestedCC
> > myValue="#{personBean.person.adresse}"/>
> >                        </ui:remove>
> >
> >                        c) NPE!!! <parts-test:nestedCC
> > myValue="#{personBean.person.adresse.plz}"/>
> >
> >                </ui:define>
> >
> >        </ui:composition>
> >
> > CustomComponent:
> >
> >        <composite:interface>
> >                <composite:attribute name="myValue" required="true" />
> >        </composite:interface>
> >
> >       <composite:implementation>
> >
> >                <ui:remove>
> >                        a) works <h:inputText id="theValue"
> > value="#{cc.attrs.myValue.adresse.plz}" />
> >                        b) works <h:inputText id="theValue"
> > value="#{cc.attrs.myValue.plz}" />
> >                </ui:remove>
> >
> >                    c) NPE!!! <h:inputText id="theValue"
> > value="#{cc.attrs.myValue}" />
> >
> >        </composite:implementation>
> >
> > The code behind the scenes is:
> > - a managed bean "PersonBean"
> > - ...which refers to an object "Person" which refers to an object
> "Adresse"
> > which has a string property "plz"
> > - for testing purposes I implemented some get/setPlz in PersonBean
> and
> > Person too which provide the value stored in Adresse.plz
> >
> > In case c), using a deeply nested EL expression, the NPE occurs.
> >
> > In the ExtVal code I found in
> >
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getProp
> ertyDetailsOfValueBinding(UIComponent):
> >
> > @ToDo(value = Priority.HIGH, description = "check if it works with
> nested
> > composite components")
> >
> > Is this TODO still an open one or is the EL expression revealing a
> new bug?
> >
> > --
> > WM 2010: Top News, Spielpläne, Public Viewing-Termine, E-Cards und
> alles,
> > was der Fan sonst noch braucht, gibt´s im Sport-Channel auf arcor.de.
> > http://www.arcor.de/rd/footer.wm2010
> >


Re: ExtVal: NullPointer during EL resolving for custom component

Posted by Gerhard Petracek <ge...@gmail.com>.
hi tom,

we have to check if it is an issue of the jsf impl. you are using.
the todo was placed there, because there were some changes in the jsf
implementations.

it would be nice if you can provide a link to a small demo app which
illustrates the issue.
(-> not everybody of the community who would like to debug the issue has to
create the demo app.)

regards,
gerhard

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces



2010/6/29 <my...@arcor.de>

> Hi,
>
> the following NPE occured using Myfaces ExtVal:
>
> java.lang.NullPointerException
>        at
> javax.faces.component.UIComponent.getValueExpression(UIComponent.java:338)
>        at
> com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.getExpression(CompositeComponentAttributesELResolver.java:314)
>        at
> org.apache.myfaces.extensions.validator.core.el.ExtValELResolver.getCompositeComponentExpression(ExtValELResolver.java:277)
>        at
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(DefaultELHelper.java:169)
>        at
> org.apache.myfaces.extensions.validator.core.metadata.extractor.DefaultComponentMetaDataExtractor.extract(DefaultComponentMetaDataExtractor.java:77)
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.getPropertyInformation(AbstractValidationInterceptor.java:176)
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.processAfterValidation(AbstractValidationInterceptor.java:166)
>        at
> org.apache.myfaces.extensions.validator.core.interceptor.AbstractValidationInterceptor.beforeGetConvertedValue(AbstractValidationInterceptor.java:153)
>        at
> org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererWrapper.getConvertedValue(ExtValRendererWrapper.java:369)
>        at
> javax.faces.component.UIInput.getConvertedValue(UIInput.java:1008)
>        at javax.faces.component.UIInput.validate(UIInput.java:934)
>        at javax.faces.component.UIInput.executeValidate(UIInput.java:1189)
>        at javax.faces.component.UIInput.processValidators(UIInput.java:691)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
>        at javax.faces.component.UIForm.processValidators(UIForm.java:243)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
>        at
> javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1080)
>        at
> javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1180)
>        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:118)
>        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
>
>
> I used the following code:
>
> Page:
>
>          <ui:composition
> template="/resources/templates/test-template.xhtml">
>
>                <ui:define name="test-workspace">
>
>                        <ui:remove>
>                                a) works <parts-test:nestedCC
> myValue="#{personBean.person}"/>
>                                b) works <parts-test:nestedCC
> myValue="#{personBean.person.adresse}"/>
>                        </ui:remove>
>
>                        c) NPE!!! <parts-test:nestedCC
> myValue="#{personBean.person.adresse.plz}"/>
>
>                </ui:define>
>
>        </ui:composition>
>
> CustomComponent:
>
>        <composite:interface>
>                <composite:attribute name="myValue" required="true" />
>        </composite:interface>
>
>       <composite:implementation>
>
>                <ui:remove>
>                        a) works <h:inputText id="theValue"
> value="#{cc.attrs.myValue.adresse.plz}" />
>                        b) works <h:inputText id="theValue"
> value="#{cc.attrs.myValue.plz}" />
>                </ui:remove>
>
>                    c) NPE!!! <h:inputText id="theValue"
> value="#{cc.attrs.myValue}" />
>
>        </composite:implementation>
>
> The code behind the scenes is:
> - a managed bean "PersonBean"
> - ...which refers to an object "Person" which refers to an object "Adresse"
> which has a string property "plz"
> - for testing purposes I implemented some get/setPlz in PersonBean and
> Person too which provide the value stored in Adresse.plz
>
> In case c), using a deeply nested EL expression, the NPE occurs.
>
> In the ExtVal code I found in
> org.apache.myfaces.extensions.validator.core.el.DefaultELHelper.getPropertyDetailsOfValueBinding(UIComponent):
>
> @ToDo(value = Priority.HIGH, description = "check if it works with nested
> composite components")
>
> Is this TODO still an open one or is the EL expression revealing a new bug?
>
> --
> WM 2010: Top News, Spielpläne, Public Viewing-Termine, E-Cards und alles,
> was der Fan sonst noch braucht, gibt´s im Sport-Channel auf arcor.de.
> http://www.arcor.de/rd/footer.wm2010
>