tags:

views:

329

answers:

2

Hi All,

I am using spring in my application , When i am loading the springApplicationContext to get the beans i am getting the errors

Caused by: org.springframework.beans.InvalidPropertyException: Invalid property "abc"

Even though there is a property abc and the setter for that property in the bean.

This is a weird error i know , but i can't figure out where is the problem.

Any pointers will be helpful.

Thanks! Pratik

+1  A: 

Ensure that the property has both a public setter and getter. In case of an AnyObject property it should look like:

private AnyObject abc;
public AnyObject getAbc() { return abc; }
public void setAbc(AnyObject abc) { this.abc = abc; }

There is however one special case: in case of a boolean property it should look like:

private boolean abc;
public boolean isAbc() { return abc; }
public void setAbc(boolean abc) { this.abc = abc; }

Note the is prefix instead of get.

BalusC
Getter is **not** necessary. If it **is** declared, then it indeed needs to conform to javabean spec (btw, `isXXX` is also optional for booleans; `getXXX` works just as well).
ChssPly76
A: 

I remeber the similar question at Spring forums. It was found out that there was a setter signature like

public class MyClass {

    private Aggregated field;

    public MyClass setField(Aggregated field) {
        this.field = field;
    }
}

I.e. the setter's return type was not void.

Anyway, Spring uses standard Instrospector for processing class properties. Try it with your class and check if target property is found.

denis.zhdanov