I have defined an Employee object with the following properties
public class Employee {
private String id;
private String name;
private Address address;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
The Address object:
public class Address {
private String street;
private String city;
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
And have generated the getters and setters for the properties. When I do the following on the properties:
String value = BeanUtils.getNestedProperty(employee, "address.street");
I get a "No Such Method Exception" for address.street.
java.lang.NoSuchMethodException: Unknown property 'address.street' on class 'class com.test.xm.Employee'
The fields id and name works fine.
Have double checked the getters and setters and it seems fine. What possibly could I be doing wrong here?
Edit: Have updated the getters and setters.