This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
recently upgraded a webapp from struts 1.1b2 to 1.2.4, code that previously worked:
spent quite a lot of time looking at the interfaces, consulting struts doc, scratching head, etc. googled the issue and found lots of cases where the property was incorrectly specified, breaking the introspection, or the get and set dealt w/ diff types. but that's not the case here.
tried several things, trying to get head around the problem. this variation works fine, but does not explain why bean:write cannot find the appropriate getter:
added other attrs to the tag based on struts doc. still, the error persists:
this worked. the toString of the activity was called, but still the tru answer was not revealed:
here is the interface and impl for reference (javadoc, etc removed):
Java Developer, Thailand
Joined: Nov 22, 2008
good eye! actually, i do have a getID() method. it is on the class which Activity extends. the bean dump util saw it too, but i had omitted it from the output snippet in the original posting.
but accessing the ID is not the problem. the issue ("No getter for property name on bean activity") arrises only with <bean:write name="activity" property="name"/>. this code however: <%= activity.getName() %>, works just fine.
am certain that using <bean:write name="activity" property="ID"/> would exhibit the same problem as the use of bean:write to access the name attribute. in fact, i tried <bean:write name="activity" property="description"/> and met with "No getter for property description on bean activity"
am feeling that it is a scope issue for the bean:write tag. the jsp page-scope bean "activity" (set by the iterate tag) is not accessible to bean:write. cannot discern how to prove that hunch or how to resolve the issue w/in the time allowed.
have decided to explore spring for the ui of this app for a number of reasons, but am still keen to understanding why this struts issue came into being when the only things that changed were our going from struts 1.1b2 to 1.2.4 and from jdk1.4.x to 1.5. that is a key consideration: this code worked fine w/ older struts and older jdk.
I'm pretty sure it's not a scope issue. If it were, the message would say that the bean activity was not found.
This seems to me a problem in reflection. WHERE, I am not sure.
A good workman is known by his tools.
Joined: Nov 22, 2008
good point. after all, <%= activity.getName() %> works, so "activity" is available. <bean:write name="activity"> also works. it calls the toString on the bean just like the doc says it would. but put property="name" back in the bean:write, and the "No getter..." error returns.
i've continued messing with this off an on. the bean dump util says the class (activity.getClass()) is indeed JDBCActivity (which extends Activity and has a getName() method). tried to doctor up the generated code in tomcat hoping to get some insight. still stumped by this.