0

We are facing an issue in IBM RAD IDE environment (IBM JDK 1.6 as the runtime JRE) while executing a test case. The same code is running fine with Springsource IDE (Sun JDK 1.6 as the runtime JRE). Is it an issue with JDK or with Spring framework. Brief code history : There is a java bean as below

class User {
             final Map<Integer,String> securityQuestions = Collections.synchronizedMap(new HashMap<Integer,String>(MAX_SECURITY_QUESTIONS));
            final Map<Integer,String> securityAnswers = Collections.synchronizedMap(new HashMap<Integer,String>(MAX_SECURITY_QUESTIONS));

      public Map<Integer,String> getSecurityAnswers() {
            return securityAnswers;
        }

    public void setSecurityAnswer(Integer answerNumber, String answerText) {
            securityAnswers.put(answerNumber, answerText);
        }
   }

when we are trying to validate the 'securityAnswers' using

ValidationUtils.rejectIfEmptyOrWhitespace(errors, "securityAnswers", "seqQans.obj.required","security Question list cannot be empty");

we are getting this exception.

Caused by: org.springframework.beans.NotReadablePropertyException: Invalid property 'securityAnswers' of bean class [User]: Bean property 'securityAnswers' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:705) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:697) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99) at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:226) at org.springframework.validation.ValidationUtils.rejectIfEmptyOrWhitespace(ValidationUtils.java:224) at org.springframework.validation.ValidationUtils.rejectIfEmptyOrWhitespace(ValidationUtils.java:182)

Sandeep
  • 586
  • 2
  • 6
  • 17
  • are you sure IBM RAD IDE environment has compiled User in place? I suspect it is missing updated User. – kosa Jan 24 '12 at 19:20
  • Yes, I guess so. can you elaborate on 'missing updated user'.. – Sandeep Jan 24 '12 at 19:30
  • What I meant was, your RAD Runtime might not have compiled User class with securityAnswers. I would suggest do a complete cleanup and rebuild. – kosa Jan 24 '12 at 19:31
  • thanks. I am certain that he has compiled, because the same code works when deployed as an application IDM Websphere. However, in the RAD IDE, the test case reports this issue. I was wondering if this post is related..http://stackoverflow.com/questions/8849042/beanwrapperimpl-issues-only-with-websphere ... – Sandeep Jan 24 '12 at 19:34

1 Answers1

0

Sorry ! but I don't believe RAD has anything to do with this.The exception clearly states the reason why this is happening:

Does the return type of the getter match the parameter type of the setter?

Answer is no :)

Liam
  • 2,837
  • 23
  • 36
  • thanks, but if this is a code level issue, we should get similar exception thrown for all tests. This works fine in my Springsource IDE. I am thinking that the getter method (readMethod()) is checked against and lenient with the setter method argument.. – Sandeep Jan 24 '12 at 20:12
  • I think the issue is in SecurityAnswers getter and setter. Try changing the parameter of setSecurityAnswers to a map. – Liam Jan 24 '12 at 20:19
  • https://jira.springsource.org/browse/SPR-8806 https://jira.springsource.org/browse/SPR-8347 are both related to this issue I guess.. however, we can try have a same matching read and write method names – Sandeep Jan 24 '12 at 21:01
  • Yes do try, I think that should solve this issue pretty much. – Liam Jan 24 '12 at 21:07