i'm trying access spring initialized properties within mule groovy script without success.
loading property file in mule application xml:
<context:property-placeholder location="application.properties"/>
contents of property file:
key=value
accessing property inside application xml works fine:
<logger message="key: ${key}" level="info" doc:name="logger" />
produces following output:
key: value
attempting same in groovy script:
log.info "key: ${key}"
results in exception:
exception stack is: 1. no such property: key class: script1 (groovy.lang.missingpropertyexception) org.codehaus.groovy.runtime.scriptbytecodeadapter:53 (null) 2. groovy.lang.missingpropertyexception: no such property: key class: script1 (javax.script.scriptexception) org.codehaus.groovy.jsr223.groovyscriptengineimpl:326 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/scriptexception.html) 3. failed invoke scriptcomponent{main-flow.component.32928685}. component caused exception is: scriptcomponent{main-flow.component.32928685}. message payload of type: contentlengthinputstream (org.mule.component.componentexception) org.mule.component.abstractcomponent:144 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/component/componentexception.html) ******************************************************************************** root exception stack trace: groovy.lang.missingpropertyexception: no such property: key class: script1 @ org.codehaus.groovy.runtime.scriptbytecodeadapter.unwrap(scriptbytecodeadapter.java:53) @ org.codehaus.groovy.runtime.callsite.pogogetpropertysite.getproperty(pogogetpropertysite.java:52) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.callgroovyobjectgetproperty(abstractcallsite.java:307) @ script1.run(script1.groovy:18) <snip>
i'm assuming properties available somewhere within groovy script context references available script, i've found no documentation on how navigate them. i've looked through javadocs, have been unable piece proper method spring initialized property resolution. appreciated.
thanks, steve
i found answer question in following post. in short,
spring property placeholders resolved @ configuration time , not stored anywhere, cant loaded afterwards.
if need store can inject them bean , retrieve registry.
based on answer provided above, behavior may have changed in newer releases of mule runtime, experience using version 3.5.4 consistent other post's description of how spring properties evaluated mel interpreter.
- steve
Comments
Post a Comment