PDA

View Full Version : Phonebook sample attribute-mapper bug (preview 3)



RayKrueger
Jul 1st, 2005, 10:56 AM
The phonebook sample in preview 3 is busted right now, and I don't see how to fix it yet...

The seach-flow.xml file declares the following...


<subflow-state id="showDetails" flow="person.Detail">
<attribute-mapper>
<input value="$&#123;sourceEvent.parameters.id&#125;" as="id" type="long"/>
</attribute-mapper>
<transition on="finish" to="executeQuery"/>
<transition on="error" to="error"/>
</subflow-state>


Bring up the phonebook sample, enter in any name, and click on it. You will get the following yack on your shoes :P



org.springframework.beans.NotReadablePropertyExcep tion&#58; Invalid property 'sourceEvent.parameters.id' of bean class &#91;org.springframework.web.flow.execution.servlet.Se rvletEvent&#93;&#58; Bean property 'sourceEvent.parameters.id' is not readable or has an invalid getter method&#58; Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPrope rtyValue&#40;BeanWrapperImpl.java&#58;634&#41;
org.springframework.beans.BeanWrapperImpl.getPrope rtyValue&#40;BeanWrapperImpl.java&#58;626&#41;
org.springframework.binding.expression.support.Bea nWrapperEvaluator.evaluate&#40;BeanWrapperEvaluator.ja va&#58;25&#41;
org.springframework.binding.support.Mapping.map&#40;Ma pping.java&#58;91&#41;
org.springframework.binding.support.Parameterizabl eAttributeMapper.map&#40;ParameterizableAttributeMappe r.java&#58;174&#41;
org.springframework.web.flow.support.Parameterizab leFlowAttributeMapper.createSubflowInput&#40;Parameter izableFlowAttributeMapper.java&#58;218&#41;
org.springframework.web.flow.SubflowState.createSu bflowInput&#40;SubflowState.java&#58;224&#41;
org.springframework.web.flow.SubflowState.doEnter&#40; SubflowState.java&#58;198&#41;
org.springframework.web.flow.State.enter&#40;State.jav a&#58;164&#41;
org.springframework.web.flow.Transition.execute&#40;Tr ansition.java&#58;269&#41;
org.springframework.web.flow.TransitionableState.o nEvent&#40;TransitionableState.java&#58;202&#41;
org.springframework.web.flow.execution.impl.FlowEx ecutionImpl.signalEvent&#40;FlowExecutionImpl.java&#58;317 &#41;
org.springframework.web.flow.execution.FlowExecuti onManager.onEvent&#40;FlowExecutionManager.java&#58;289&#41;
org.springframework.web.flow.execution.FlowExecuti onManager.onEvent&#40;FlowExecutionManager.java&#58;245&#41;
org.springframework.web.flow.execution.servlet.Ser vletFlowExecutionManager.handle&#40;ServletFlowExecuti onManager.java&#58;77&#41;
org.springframework.web.flow.mvc.FlowController.ha ndleRequestInternal&#40;FlowController.java&#58;137&#41;
org.springframework.web.servlet.mvc.AbstractContro ller.handleRequest&#40;AbstractController.java&#58;128&#41;
org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle&#40;SimpleControllerHandlerAda pter.java&#58;44&#41;
org.springframework.web.servlet.DispatcherServlet. doDispatch&#40;DispatcherServlet.java&#58;684&#41;
org.springframework.web.servlet.DispatcherServlet. doService&#40;DispatcherServlet.java&#58;625&#41;
org.springframework.web.servlet.FrameworkServlet.s erviceWrapper&#40;FrameworkServlet.java&#58;386&#41;
org.springframework.web.servlet.FrameworkServlet.d oGet&#40;FrameworkServlet.java&#58;346&#41;
javax.servlet.http.HttpServlet.service&#40;HttpServlet .java&#58;689&#41;
javax.servlet.http.HttpServlet.service&#40;HttpServlet .java&#58;802&#41;

Keith Donald
Jul 1st, 2005, 12:50 PM
Everyone runs into this. You need OGNL in your classpath :-)

This issue is fixed / clarified for PR4 (which will likely be 1.0 RC1)

RayKrueger
Jul 1st, 2005, 01:28 PM
Doh! I did have it in my classpath, but I didn't have the IDE set right to deploy it to the webapp...

Thanks!

What's interesting is if you search the forums for NotReadablePropertyException, you will get no results. I just did a quick search now for phonebook and I see other posts with the same problem. Searching the forums for NotReadablePropertyException won't return this post even :P

NicolasPeeters
Jan 11th, 2006, 12:57 PM
Hi,

I am having a similar issue (not with the PhoneBook example though). I am using Spring 1.2.6 and SWF pr5. Please have a look at the following code.

JSP Code:


<spring:bind path="project.assets">
<select name="assets" size="6" multiple>
<c:forEach var="myAsset" items="${assets}">
<option value="<c:out value="${myAsset.id}"/>">
<c:out value="${myAsset.id}"/>
</option>
</c:forEach>
</select>
</spring:bind>

FormAction initBinder Code. Here I register a custom property editor.


protected void initBinder(RequestContext context, DataBinder binder) {
binder.registerCustomEditor(Set.class, "assets", new CustomCollectionEditor(Set.class) {
// converts the int id into an Asset instance,
// by looking in up in the DAO
protected Object convertElement(Object element) {
Asset asset = null;
if (element != null) {
int id = new Integer((String)element);
asset = (Asset) projectService.getAssetById(id);
log.debug("Retrieved Asset (from Hibernate) with element with id:"+id+" from the formObject.");
}
return asset;
}
});
}



What is annoying is that this code seems to work in the Unit Test I've written (Asset are lookup up and added to my Set<Asset> in my parent object), but not when deployed to Tomcat.

This is the stacktrace:



org.apache.jasper.JasperException: Invalid property 'assets.name' of bean class [com.accenture.adsj.appstyles.web.core.business.bo. Project]: Bean property 'assets.name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)
org.springframework.web.servlet.view.InternalResou rceView.renderMergedOutputModel(InternalResourceVi ew.java:97)
org.springframework.web.servlet.view.AbstractView. render(AbstractView.java:250)
org.springframework.web.servlet.DispatcherServlet. render(DispatcherServlet.java:961)
org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:738)
org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:658)
org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:392)
org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:357)
javax.servlet.http.HttpServlet.service(HttpServlet .java:709)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)

root cause

org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'assets.name' of bean class [com.accenture.adsj.appstyles.web.core.business.bo. Project]: Bean property 'assets.name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:387)
org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:379)
org.springframework.validation.BindException.getFi eldValue(BindException.java:337)
org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:117)
org.springframework.web.servlet.tags.BindTag.doSta rtTagInternal(BindTag.java:115)


I am not whether my problem is due to bad coding in the PropertyEditor, or if it has something to do with the Spring (or SWF) version I am using.
I checked that OGNL (2.6.7) was in my classpath.

Any help would be greatly appreciated!

Thanks!!

Nicolas

curtney
Jan 12th, 2006, 12:38 AM
Greetings!



org.apache.jasper.JasperException: Invalid property 'assets.name' of bean class [com.accenture.adsj.appstyles.web.core.business.bo. Project]: Bean property 'assets.name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?


Check your method signature. The error says that it cannot read the following property: 'assets.name'. Does this property exists in your Project business object? Is that method 'private'? How about the spelling?

Hopes this helps,

Curtney

NicolasPeeters
Jan 12th, 2006, 02:01 AM
Hi Curtney,

Thanks for your fast answer.

No assets does _not_ exist in Project. My Project class has a Set<Asset>.

The Asset class has id, name, description as member variables. It's a private attribute, and the getters/setters are auto-generated (and are OK).
What I don't understand is that my code doesn't even use the Asset.name property...

Thinking about it, I might have this issue because of the special binding I am trying to make. I am trying to bind the content of a multi-select list (could be a list of checkboxes as well) to a Set in my parent object (any sort of collection would be fine). I have therefore written the little binder (see the code snippet in my original posting...)...

Any thoughts?

Thanks!

Nicolas

NicolasPeeters
Jan 12th, 2006, 05:54 AM
Hi all,

I solved the problem. I was actually looking in the wrong place. There was another "assets.name" somewhere else in my flow (and I didn't expect it to go there, so I didn't look). My apologies for that.

There might still be something wrong with my propertyEditor... but at leat I can continue now.
Thanks a lot for your support.

Nicolas