Results 1 to 5 of 5

Thread: getters and setters on Abstract parents

  1. #1

    Default getters and setters on Abstract parents

    I have an Abstract parent class which defines all of the setters and getters for my concrete sub-classes (which implement a template method invoked by the abstract parent).

    I can load my bean.xml just fine but if I try and instantiate an instance of one of my beans I get the exception below. Thing is, none of what it's complaining about is true! The setters/getters are all public, there is a public no-argument ctor (otherwise spring would have complained on loading the bean.xml) and the class definition hasn't changed.

    Only thing I can think of is that spring can't invoke the public getters/setters which are defined on the abstract parent; which kind of looks like a big hole in Spring's support of inheritance which in turn makes me think I must be wrong so anyone have an idea?

    I'm going to re-factor these classes to use a strategy instead of a template method anyway but it would be nice to know for the future.

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'backupActionBean' defined in class path resource [beans.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.FatalBeanException: Could not instantiate class [com.pti.dbmulti.ui.BackupAction]; has class definition changed? Is there a public no-arg constructor?; nested exception is java.lang.IllegalAccessException: Class org.springframework.beans.BeanUtils can not access a member of class com.pti.dbmulti.ui.BackupAction with modifiers "public"
    org.springframework.beans.FatalBeanException: Could not instantiate class [com.pti.dbmulti.ui.BackupAction]; has class definition changed? Is there a public no-arg constructor?; nested exception is java.lang.IllegalAccessException: Class org.springframework.beans.BeanUtils can not access a member of class com.pti.dbmulti.ui.BackupAction with modifiers "public"
    java.lang.IllegalAccessException: Class org.springframework.beans.BeanUtils can not access a member of class com.pti.dbmulti.ui.BackupAction with modifiers "public"
    at sun.reflect.Reflection.ensureMemberAccess(Reflecti on.java:57)
    at java.lang.Class.newInstance0(Class.java:302)

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    could you provide your applicationContext.xml ?
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3

    Default Problem solved.

    All the necessary methods and the ctor were public: but the class itself wasn't.

  4. #4
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Only thing I can think of is that spring can't invoke the public getters/setters which are defined on the abstract parent; which kind of looks like a big hole in Spring's support of inheritance which in turn makes me think I must be wrong so anyone have an idea?
    To clarify: Spring fully supports inherited properties. However, there is a problem if the class those properties are inherited from isn't public, as in this case. That would be a problem if you wanted to wire that class normally using Java code: it isn't really to do with Spring.

    Rgds
    Rod
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  5. #5

    Default

    Quote Originally Posted by Rod Johnson
    Only thing I can think of is that spring can't invoke the public getters/setters which are defined on the abstract parent; which kind of looks like a big hole in Spring's support of inheritance which in turn makes me think I must be wrong so anyone have an idea?
    To clarify: Spring fully supports inherited properties. However, there is a problem if the class those properties are inherited from isn't public, as in this case. That would be a problem if you wanted to wire that class normally using Java code: it isn't really to do with Spring.

    Rgds
    Rod
    Absolutely: mea culpa, mea maxima culpa.

Similar Threads

  1. Replies: 2
    Last Post: Sep 19th, 2005, 04:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •