PDA

View Full Version : Bug in sellitem webapp in PR3?



deanholdren
May 27th, 2005, 02:46 PM
I'm getting the following error when trying the sellitem app in PR3:


500 Servlet Exception
org.springframework.beans.NotReadablePropertyExcep tion: Invalid property
'flowScope.sale' of bean class [org.springframework.web.flow.execution.impl.State ContextImpl]:
Bean property 'flowScope.sale' is not readable or has an invalid getter
method: Does the return type of the getter match the parameter type of
the setter?
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:634)
at org.springframework.beans.BeanWrapperImpl.getNeste dBeanWrapper(BeanWrapperImpl.java:535)
at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:513)
at org.springframework.beans.BeanWrapperImpl.getBeanW rapperForPropertyPath(BeanWrapperImpl.java:514)
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:624)
at org.springframework.binding.expression.support.Bea nWrapperEvaluator.evaluate(BeanWrapperEvaluator.ja va:25)
at org.springframework.web.flow.config.TextToTransiti onCriteria$ExpressionTransitionCriteria.test(TextT oTransitionCriteria.java:133)
at org.springframework.web.flow.Transition.matches(Tr ansition.java:228)
at org.springframework.web.flow.TransitionableState.g etTransition(TransitionableState.java:166)
at org.springframework.web.flow.TransitionableState.g etRequiredTransition(TransitionableState.java:179)
at org.springframework.web.flow.DecisionState.doEnter (DecisionState.java:110)
at org.springframework.web.flow.State.enter(State.jav a:164)
at org.springframework.web.flow.Transition.execute(Tr ansition.java:269)
at org.springframework.web.flow.TransitionableState.o nEvent(TransitionableState.java:202)
at org.springframework.web.flow.execution.impl.FlowEx ecutionImpl.signalEvent(FlowExecutionImpl.java:317 )


Is this a known problem, or is it my configuration? I'm using Spring 1.2

klr8
May 28th, 2005, 03:37 AM
The problem is that you don't have the ognl.jar in the WEB-INF/lib of the sellitem.war. As a result the ExpressionParserUtils will use the BeanWrapperExpressionParser instead of the OgnlExpressionParser and ${flowScope.sale.shipping} is obviously an OGNL expression and not a bean property path.

Just putting ognl.jar (www.ognl.org) in WEB-INF/lib should fix the problem. How did you build the sellitem.war?

Erwin

deanholdren
May 31st, 2005, 09:05 AM
Thanks, I'm bulding using build.bat. I fixed the locations for the jar files in the build.properties file and it included the jars in the built war, tested and it worked.

thanks for explaining the problem

alesj
Jun 1st, 2005, 04:27 AM
It is the same in TSS article: http://www.theserverside.com/articles/article.tss?l=SpringWebFlow

<subflow-state id="enterPassengerInformation" flow="passenger">

<attribute-mapper>
<input value="${requestScope.passenger.id}" as="passengerId"/>
</attribute-mapper>
<transition on="finish" to="displayReservationVerification"/>
</subflow-state>

This wouldn't work in environment without OGNL.

Although Scope implements Map, Spring's BeanWrapperImpl doesn't know where to get passanger property. It looks for a getter/setter and not into the map.

Map map = new HashMap();
map.put("passanger", "Ales");
try {
Object value = null;
//value = Ognl.getValue("passanger", new HashMap(), map);
value = new BeanWrapperImpl(map).getPropertyValue("passanger");
System.out.println("value = " + value);
} catch (Exception e) {
e.printStackTrace();
}

org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'passanger' of bean class [java.util.HashMap]: Bean property 'passanger' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:634)
at org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:626)
at Test.main(Test.java:32)

So it is necessary to point out that you need OGNL in order this to work. Since BeanWrapper's ExpressionEvaluator implementation is insufficient here - and this should be mentioned.

But it would be good if this wouldn't totaly depend on ONGL. With Spring already very powerful, it's probably not a big deal to put something similar (treating Map similar as JavaBean) in it.

Rgds, Ales

klr8
Jun 3rd, 2005, 09:05 AM
You are correct in saying that you need OGNL for that to work, we should get that clarified in the article.

Regarding making BeanWrapper more powerfull so that it can handle things like a map, I suggest you post a request for enhancement on the Spring JIRA issue tracker.

Erwin