Groovy property setting error
Hi,
I have simple description
<lang:groovy id="messenger" script-source="classpath:org/springframework/scripting/groovy/Messenger.groovy">
<lang:property name="message" value="Hello World!"/>
</lang:groovy>
but I get error:
Exception in thread "main" org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'setup' defined in class path resource [myrsik1.xml]: Cannot resolve reference to bean 'messenger' while setting constructor argument with key [0]; nested exception is
org.springframework.beans.factory.BeanCreationExce ption:
Error creating bean with name 'messenger': Error setting property values;
nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'message' of bean class [org.springframework.scripting.groovy.GroovyScriptF actory]:
Bean property 'message' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'messenger': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'message' of bean class [org.springframework.scripting.groovy.GroovyScriptF actory]: Bean property 'message' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'message' of bean class [org.springframework.scripting.groovy.GroovyScriptF actory]: Bean property 'message' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:699)
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:575)
at org.springframework.beans.AbstractPropertyAccessor .setPropertyValue(AbstractPropertyAccessor.java:49 )
at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor.java:6 8)
at org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor.java:5 7)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:813)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:589)
Why property is not writable?
Groovy doesn't need setter method?
Please help
Thanks
tom
Catch fatal exception during invalid script loading
Hi Rick
Problem solved, Thanks!!
Sorry to bother you again,
Spring is great but learning takes some time :)
I have dynamic data flow router implemented in Groovy.
I want to use 'refreshable bean' feature.
I understand what script must be tested before usage but still it’s possible what script is invalid.
Any exceptions relating to refreshing the script (such as encountering a compilation error, or finding that the script file has been deleted) will result in a fatal exception being propagated to the calling code.
Loading script (and compilation error) occurs then router receives incoming message.
Due to compilation error incoming message is lost.
Actually router itself is fully functional (using previous error-free Groovy script) and next messages are handled correctly.
So the only bad thing is lost message during invalid Groovy script loading.
Is where any possibility to change behavior?
Catch fatal exception and still let router execute previous correct Groovy code?
Tom