I’m working with some Java that I generate with JAXB but I don’t think the JAXB is the problem since the structure of the code generated matches the getter and setter methods for Spring properties that now work but earlier on gave me this same type of exception.
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property ‘previousCurrentEstateNo’ of bean class [ca.qc.ic.osb.efilingClasses.EIS]: Bean property ‘previousCurrentEstateNo’ is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
The difference here is the use of a String array. I’ve tried the various suggestions that are supposed to work without success. I’m using Spring 3.0.6.
<bean id="eisJointSummary" class="ca.qc.ic.osb.efilingClasses.EIS"
scope="prototype" lazy-init="true">
<property name="previousCurrentEstateNo" >
<list>
<value>1234</value>
</list>
</property>
</bean>
within EIS class:
public static class Estate
{
protected String[] previousCurrentEstateNo;
public String[] getPreviousCurrentEstateNo() {
if (this.previousCurrentEstateNo == null) {
return new String[ 0 ] ;
}
String[] retVal = new String[this.previousCurrentEstateNo.length] ;
System.arraycopy(this.previousCurrentEstateNo, 0, retVal, 0, this.previousCurrentEstateNo.length);
return (retVal);
}
public String getPreviousCurrentEstateNo(int idx) {
if (this.previousCurrentEstateNo == null) {
throw new IndexOutOfBoundsException();
}
return this.previousCurrentEstateNo[idx];
}
public int getPreviousCurrentEstateNoLength() {
if (this.previousCurrentEstateNo == null) {
return 0;
}
return this.previousCurrentEstateNo.length;
}
public void setPreviousCurrentEstateNo(String[] values) {
int len = values.length;
this.previousCurrentEstateNo = ((String[]) new String[len] );
for (int i = 0; (i<len); i ++) {
this.previousCurrentEstateNo[i] = values[i];
}
}
public String setPreviousCurrentEstateNo(int idx, String value) {
return this.previousCurrentEstateNo[idx] = value;
}
Thanks
You are creating a bean of the type
ca.qc.ic.osb.efilingClasses.EISand that class doesn’t have apreviousCurrentEstateNoproperty.From what I can tell from the information you provided the
previousCurrentEstateNois a property ofEstate.I am assuming that
EIShas a property of typeEstate?Try something to this effect: