Reputation: 8193
I have a clojure class which I initialize using spring bean initialization.
My setter method is as follows
(defn -setCompanyName [currency] (println (str "company : " company)))
Bean initialization is as follows
<bean id="company" class="test.Company" p:companyName="orce"/>
I'm getting following error.
Invalid property 'companyName' of bean class [test.Company]: Bean property 'companyName' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Does anyone knows the root cause for this issue.
Regards Isuru.
Upvotes: 2
Views: 546
Reputation: 696
Don't you need another function parameter? The first acts as a 'this' pointer. I can't test this right now as I'm on my phone.
Upvotes: 0
Reputation: 8591
There are several possible causes for this particular issue, so without all your code it is difficult to say what is failing.
Here is the code that works for me:
(ns test)
(gen-class
:main false
:name test.Company
:methods [[setCompanyName [String] void]])
(defn -setCompanyName [this company] (println (str "company : " company)))
Notes:
I find very useful the javap command to see what gen-class is generating:
javap.exe -classpath classes/ test.Company
public class test.Company extends java.lang.Object{
public static {};
public test.Company();
public java.lang.String toString();
public boolean equals(java.lang.Object);
public java.lang.Object clone();
public int hashCode();
public void setCompanyName(java.lang.String);
}
I will also recommend you to look at the second example on http://clojuredocs.org/clojure_core/clojure.core/gen-class to see how to manage state.
Upvotes: 3