Nicholas
Nicholas

Reputation: 7501

Using Mule Expressions in a Spring Configuration

I'm setting up a Mule application and in it, I wanted to use Spring beans to wire up an EHCache and JDBC connection. Instead of putting the configuration information in each Mule application I create, I wanted to use a properties file which would be located at $mule_home/conf.

I know how to use a Mule expression to access the Mule home directory(#[mule:context.homeDir]) but when I attempt to put that expression inside my context.xml file, which I link in my mule application configuration, and start up the server, I get a

java.io.FileNotFoundException: #[mule:context.homeDir]\conf\jdbc.properties (The system cannot find the path specified)

Even if I create a seperate property in the mule configuration, ${homeDir} which has a value of #[mule:context.homeDir] it gives me the same error, except with ${homeDir} as being unable to resolve.

I've turned logging up and can see it wiring up the property ${homeDir}, but it seems the the property-placeholder does not want to resolve it. I've tried both and using a raw bean of the class of PropertyPlaceholderConfigurer:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>file:#[mule:context.homeDir]/conf/jdbc.properties</value>
            <value>file:#[mule:context.homeDir]/conf/standalone-ehcache.conf</value>
            <value>classpath:gateway.properties</value>
        </list>
    </property>
</bean>

Upvotes: 2

Views: 983

Answers (1)

David Dossot
David Dossot

Reputation: 33413

${MULE_HOME}/conf is on Mule's classpath so the following should work:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
    <list>
        <value>classpath:jdbc.properties</value>
        <value>classpath:standalone-ehcache.conf</value>
        <value>classpath:gateway.properties</value>
    </list>
  </property>
</bean>

Upvotes: 2

Related Questions