commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eickvonder, Björn <Bjoern.Eickvon...@hrs.de>
Subject AW: Unknown property 'property1'?
Date Fri, 13 Nov 2009 16:38:30 GMT
Hi,

I tried your example and it works just fine for me with beanutils 1.7.0, 1.8.1, 1.8.2.
I suppose you did not post your real code, did you?

Note that if in your real code your second character of your property is uppercase things
are not as usual. This means if your Getter is getAB() you cannot access it via getProperty(...,"aB")
(resulting exactly in the exception you posted) but instead you must use getProperty(...,"AB").
As far as I know this is not a beanutils bug at all but somewhat weird within the javabean
spec or implementation itself.

For me I try to avoid uppercase characaters at the second position of my properties.

Bjoern Eickvonder 




-----Urspr√ľngliche Nachricht-----
Von: Syed Muhammad Humayun [mailto:smhumayun@iblgrp.com]
Gesendet: Fr 13.11.2009 06:38
An: user@commons.apache.org
Betreff: Unknown property 'property1'?
 
Hi,

I defined a bean:

public class MyBean {
	private String property1;
	public String getProperty1 () { return this.property1; }
	public void setProperty1 (String property1) { this.property1 =
property1; } }

And, when I call following on 'MyBean';

...
MyBean mybean = new MyBean();
PropertyUtils.getProperty(mybean, "property1"); ...

I get following exception :

java.lang.NoSuchMethodException: Unknown property 'property1'
	at
org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUti
lsBean.java:1122)
	at
org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUti
lsBean.java:686)
	at
org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean
.java:715)
	at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:29
0)

Why is this so? Why PropertyUtils is unable to see getter/setters for this
property?


-----------------------------------------------
S M Humayun
Software Architect, IBL Group
-----------------------------------------------
Cell : 92.321.8707783
Email (Official) : smhumayun@iblgrp.com
Email (Personal) : smhumayun@gmail.com
Google Talk : smhumayun@gmail.com
MSN : smhumayun2001@hotmail.com
Yahoo : humayun_reports@yahoo.com
Skype : smhumayun
AIM : syedmohdhumayun
Blog : //citrix.hrs.com/in/smhumayun
Facebook : http://www.facebook.com/smhumayun 
Twitter : http://twitter.com/smhumayun
-----------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org




Mime
View raw message