Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / March 2004

Tip: Looking for answers? Try searching our database.

java.lang.NoSuchMethodException: Property 'name' has no getter method

Thread view: 
mycoward - 12 Mar 2004 14:00 GMT
hi there,
whats wrong with this code?
thx

import org.apache.commons.beanutils.PropertyUtils;

import java.util.Map;

public class Hello {
 public static void main(String[] args) throws Exception {
   Map map = PropertyUtils.describe(new A("a"));
 }
}

class A {
 private String name;

 public A(String name) {
   this.name = name;
 }

 public A() {
 }

 public String getName() {
   return name;
 }

 public void setName(String name) {
   this.name = name;
 }
}

java.lang.NoSuchMethodException: Property 'name' has no getter method
at
org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUtils.j
ava:1180)
at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.j
ava:772)
at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:80
1)
at
org.apache.commons.beanutils.PropertyUtils.describe(PropertyUtils.java:368)
at Hello.main(Hello.java:7)
Exception in thread "main" Process terminated with exit code 1
John C. Bollinger - 12 Mar 2004 14:25 GMT
> hi there,
> whats wrong with this code?
[quoted text clipped - 34 lines]
> ava:1180)
>  at

[...]

As far as I can tell, the exception thrown is deceptive.  The "name"
property clearly has a getter (and a setter).  I'm not even sure why the
tool would complain about lack of a getter anyway, as (IIRC) it is not
required that there be one.

One possibility is that the class needs to be public.  Another (much
less likely) is that it needs to be assigned to a named package.  I also
note that technically a bean class must be Serializable, but I have
trouble imagining that being the source of your difficulty.

HTH,

John Bollinger
jobollin@indiana.edu


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.