title: Spring Bean property 'xxx' is not writable or has an invalid setter method
body: <p>I'm a Spring newbie with a seemingly simple Spring problem. I worked on this for hours without luck. Here is the exception, followed by the code (thank you in advance):</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphiteWriterSession' defined in file [/home/user/resources/jmxtrans.graphite.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'host' of bean class [com.example.ExampleClass]: Bean property 'host' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
  </code></pre>
  
  <p>My bean definitions:</p>
  
  <pre><code>&lt;bean id="graphiteWriterSession" class="com.example.ExampleClass"&gt;
      &lt;property name="host" value="host.example.com" /&gt;
      &lt;property name="port" value="2023" /&gt;
      &lt;property name="namespacePrefix" value="apps.foo.bar" /&gt;
      &lt;property name="debug" value="true" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jmxtransSession" class="com.example.MainMethodClass" factory-method="getInstance"&gt;
      &lt;property name="graphiteWriterSession" ref="graphiteWriterSession" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>The code snippet:</p>
  
  <pre><code>package com.example.ExampleClass;
  import com.googlecode.jmxtrans.model.output.GraphiteWriter;
  
  public class ExampleClass {
  
     private static final long   serialVersionUID = 1L;
     private String              host;
     private int                 port;
     private GraphiteWriter      gw;
  
    public ExampleClass() {
    }
  
    public GraphiteWriter getWriter() {
      gw = new GraphiteWriter();
      gw.addSetting(GraphiteWriter.PORT, port);
      gw.addSetting(GraphiteWriter.HOST, host);
      return gw;
    }
  
    // =====================================================
    // set/get methods for Carbon host.
    // Plugged into Spring application-context file.
    // =====================================================
    public void setCarbonHost( String host ) {
         this.host = host;
    }
  
    public String getCarbonHost() {
         return host;
    }
    // =====================================================
  
  
    // =====================================================
    // set/get methods for Carbon port.
    // Plugged into Spring application-context file.
    // =====================================================
    public void setCarbonPort( int port ) {
        this.port = port;
    }
  
    public int getCarbonPort() {
        return port;
    }
    // =====================================================
  }
  </code></pre>
  
  <p>I didn't include the driver (main method containing) class here. Although that driver class depends on the above class, the driver class itself does not have a problem (I don't believe).</p>
  
  <p>The error above shows the 'host' property as having the problem but, as you might expect, the 'port' property has the same issue (it's just so happens that the 'host' property is evaluated first).</p>
  
  <p>Can anyone tell me where I'm going wrong? Feel free to explain if you wish, as I'm not a Spring person, per se. Thank you.</p>