File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts: No getter method for property... (but not the usual suspects) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts: No getter method for property... (but not the usual suspects)" Watch "Struts: No getter method for property... (but not the usual suspects)" New topic
Author

Struts: No getter method for property... (but not the usual suspects)

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
recently upgraded a webapp from struts 1.1b2 to 1.2.4, code that previously worked:

now chokes:

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):


found a bean dump util on struts wiki. used it in jsp, hoping to get insight:

the util uses java.beans.Introspector.getBeanInfo(). it resulted in this output (and then followed by the same "No getter..." exception when it hit the bean:write):

doing this did not shed new light on the issue. according to the Java bean inspection classes, everything looks fine. further, the code did work previously. any help is greatly appreciated!

[ October 27, 2004: Message edited by: Erick Reid ]

[ October 27, 2004: Message edited by: Erick Reid ]

[ October 27, 2004: Message edited by: Erick Reid ]

[ October 27, 2004: Message edited by: Erick Reid ]

[ October 27, 2004: Message edited by: Erick Reid ]
[ October 27, 2004: Message edited by: Erick Reid ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
you not have getID() method.


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.

thoughts?
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts: No getter method for property... (but not the usual suspects)