You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Syed Muhammad Humayun <sm...@iblgrp.com> on 2009/11/13 06:38:22 UTC

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 : http://smhumayun.blogspot.com
LinkedIn : http://www.linkedin.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


AW: Unknown property 'property1'?

Posted by Eickvonder, Björn <Bj...@hrs.de>.
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