• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PropertyUtils getSimpleProperty not working for variables which have capital letters

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am trying to use reflection to get a property value from a bean using and is working fine for most of the variables.



but i am getting a run time error for few variables like etc.

Exception in thread "main" java.lang.NoSuchMethodException: Unknown property 'iPANCardNumber' on class 'class com.Person'

I was wondering if PropertyUtils doesnt like the variables with firs letter in lowercase and the next letter in upper case and wanted to get some help in this regard.

Please let me know if anyone needs more info regarding my problem and appreciate your help here.
 
Marshal
Posts: 79261
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is PropertyUtils?
 
Campbell Ritchie
Marshal
Posts: 79261
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using reflection, it si worth checking all the methods in that Person class. Maybe it is called iPanCardNumber
 
Pawan Kalyan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PropertyUtils is from org.apache.commons.beanutils.PropertyUtils. I have the variable name as iPANCardNumber and there are a bunch of beans with variable names similar to iPANCardNumber and i cant change the case of all those variables.

Hope that helps.
 
Pawan Kalyan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any more suggestions or ideas how to fix this issue ?
 
Pawan Kalyan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
are there any rules or specifications to name java class variables which are compatible for BeanUtils.getProperty like the first x number of letters should be in lower case etc etc.. ?
 
Campbell Ritchie
Marshal
Posts: 79261
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it is a variable name, why does the error message talk about methods?

Don’t know any more than that. Sorry.
 
Pawan Kalyan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because i have getter and setter methods for that variable and i guess BeanUtils does work on getter methods but not sure if does expect the method names in a particular way like first letter should be in lower case or 2nd letter should be lower case etc etc..
 
Marshal
Posts: 28235
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's a well-known "feature" of the Java Bean spec. Usually people encounter it when they try to use "eMailAddress" as a property name but your example works just as well.

It isn't that the property name has capital letters, it's that the first letter is lower-case and the second is upper-case.
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic