Drew Ingram
Drew Ingram

Reputation: 75

Property that works in CloudHub settings is not working in properties files

My app uses a public encryption key in the src/main/resources directory in a subdirectory called keys. In order to access this locally, I only need to set the path to src/main/resources/keys/<mykey>.gpg

Because the structure is different on Cloudhub, setting the above path won't work and I instead have to set it to ${app.home}/keys/<mykey>.gpg. This works when I set the property directly in Cloudhub, but when I set it in my properties file, I get the error message...

Could not resolve placeholder 'app.home' in string value 
"${app.home}/classes/keys/<mykey>.gpg"

I also can't resolve the property when I run locally. My guess is that the the properties in application-${ENV}.properties are resolved first, then the ${app.home} property is set and the Cloudhub properties are resolved last.

My question is, what can I do to ensure that ${app.home} is properly resolved from the properties file, or is there another way that I can achieve the same thing without using it? Ideally, we don't want to have to set the public key location every time we redeploy the app in Cloudhub.

Thanks!

EDIT: For greater clarity, here's where I set the property in application-DEV-properties: cibc.public.key.location=${app.home}/classes/keys/<mykey>.gpg

Upvotes: 0

Views: 334

Answers (1)

Ryan Carter
Ryan Carter

Reputation: 11606

I think this is an issue in Mule 3 in certain scenarios. Can you try setting ignore-unresolvable="true" on the property-placeholder. It should tell spring to move onto the next place to lookup.

<context:property-placeholder location="your.properties" ignore-unresolvable="true"/>

UPDATE Also try splitting the properties into two entries:

cibc.public.key.location=classes/keys/<mykey>.gpg

Then in your Mule config:

identityFile="${app.home}/${cibc.public.key.location}" 

Upvotes: 3

Related Questions