Spring Bean property 'xxx' is not writable or has an invalid setter method

The getters and setters must be public, any other access level will cause the error.


1) For host you should define public getHost() and setHost(String s)
methods, similarly for port you need getPort() and setPort(int v) methods.

This is what Spring needs to initialize your bean.

I think it needs the setter in particular (in this case).

Or ...

2) You can rename the properties in your XML file to

carbonHost and carbonPort. This should do it too.


The problem is that you are using <property name="port" value="2023" /> in your bean configuration, but the corresponding method in the ExampleClass is called setCarbonPort(int port).

Solution: update either the xml to <property name="carbonPort" value="2023" /> or the method to setPort(int port).