Announcement Announcement Module
Collapse
No announcement yet.
getters and setters on Abstract parents Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    could you provide your applicationContext.xml ?

    Comment


    • #3
      Problem solved.

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

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X