Announcement Announcement Module
No announcement yet.
org.springframework.beans.NotWritablePropertyExcep tion Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • org.springframework.beans.NotWritablePropertyExcep tion

    I have tried everything except for the right thing

    I am getting this error
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'RwControlsBinManagementController' defined in ServletContext resource [/WEB-INF/RwControlsBinManagement-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'varietyGroupManager' of bean class [com.rwcontrols.binmanagement.controller.RwControls BinManagementController]: Bean property 'varietyGroupManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

    Extract from com.rwcontrols.binmanagement.controller.RwControls BinManagementController

    <!-- Controller for the initial "Hello" page -->
    <bean id="RwControlsBinManagementController" class="com.rwcontrols.binmanagement.controller.RwC ontrolsBinManagementController">
    <property name="varietyGroupManager" ref="varietyGroupManager"/>

    <bean id="varietyGroupManager" class="com.rwcontrols.binmanagement.model.VarietyG roupManager">
    <property name="varietyGroupManagerDao" ref="varietyGroupManDao"/>

    <bean id="varietyGroupManDao" class="com.rwcontrols.binmanagement.db.VarietyGrou pManagerDaoJdbc">
    <property name="dataSource" ref="dataSource"/>

    RwControlsBinManagementController Class without imports
    public class RwControlsBinManagementController implements Controller {
    /** Logger for this class and subclasses */
    protected final Log logger = LogFactory.getLog(getClass());

    public VarietyGroupManager varietyGroupMan; /* should be private but I am desparate */

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    String now = (new java.util.Date()).toString();"returning hello view with " + now);

    Map myModel = new HashMap();

    myModel.put("now", now);
    myModel.put("varietyGroup", getVarietyGroupManager().getVarietyGroups());

    return new ModelAndView("hello", "model", myModel);

    /* types look correct and the same for the set and get */

    public void setVarietyGroupManager(VarietyGroupManager gm) {
    this.varietyGroupMan = gm;

    public VarietyGroupManager getVarietyGroupManager() {
    return this.varietyGroupMan;

    This was based on the MVC tutorial which I did get working OK before I started to modify it for my own application.


  • #2
    I have had the same problem when old jars or classes are lurking on the classpath. It might be worth checking for old copies of the class and checking there isn't an old version in a cache dir.

    A good test would be to write a new controller called something different, inject the dependency that isn't working, deploy that and see if that works. If it does work there must be old versions lurking somewhere.


    • #3
      Exactly right.

      I found that when I merged my succesfully running build for the MVC tutorial with the PetClinic build, I screwed up the build and was loading old classes with a new -servlet.xml.

      No wonder that all my poking with a sharp stick was not budging the beast.

      Now it initializes happily - it just generates a 404 with no error entries in the Tomcat logs and my application log has disappeared.

      On to the next thing.

      Thanks for the hint. It got a lot easier when I started poking in the right place. I just deleted all of the class files in my project and in Tomcat. That changed the errors to useful messages that I was able to resolve by fixing my build. (Well almost - we shall see what I did to create the current problem)

      Thanks for taking the time to respond. You saved me a lot of time and some grey hairs.