Bibek Kr. Bazaz
Bibek Kr. Bazaz

Reputation: 535

How to load properties file in Mule ESB 3.9.0 as per the environment?

I am working on Mule ESB version 3.9.0 Community Edition. I have to deploy the esb application to different environments like dev,int,prod etc. So I did the following:

mule-app.properties:
env = dev

And have created three properties files:

esb-frontoffice-dev.config.properties
esb-frontoffice-int.config.properties
esb-frontoffice-prod.config.properties

Now in the ESB Configuration file, I have defined the property-placeholder as follows:

  <context:property-placeholder location="esb-frontoffice-${env}.config.properties"/>

Then after the artifact is built, I am deploying it in the Mule ESB 3.9.0 runtime server. But I am getting the below error:

Caused by: java.io.FileNotFoundException: class path resource [esb-frontoffice-${env}.config.properties] cannot be opened because it does not exist
        at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:150) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:80) ~[spring-beans-4.1.6.RELEASE.jar:4.1.6.RELEASE]
        ... 36 more

Upvotes: 0

Views: 919

Answers (1)

aled
aled

Reputation: 25664

You need to define env as a Java property in MULE_HOME/conf/wrapper.conf.

Example:

wrapper.java.additional.23=-Denv=prod

Instead of 23 use any number not used previously in the file for other properties.

Upvotes: 1

Related Questions