jQuery in Action, 3rd edition
The moose likes Ant, Maven and Other Build Tools and the fly likes maven not populating properties from profile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "maven not populating properties from profile" Watch "maven not populating properties from profile" New topic

maven not populating properties from profile

John Gregory
Ranch Hand

Joined: Oct 05, 2006
Posts: 118
We use maven as our build tool...for better for worse. In my pom, I define a set of default properties and values for those
properties. I also create profiles and have properties set. In the application, I have a jndi properties file in which the values
are set according to the values from the pom. for example, my keystore:

in the jndi.properties file

in the pom, it's set as:

In a profile, if I'm building on a windows platform, I may set it as follows:

However, after I build my app and examine the jndi.properties file, the value of keystore is still set to ${keystore}. For every other ${} parameter I have,
the value is picked up and set from the profile, whether it's specified from a -P option or the default profile.

Has anyone seen this before and if so, what may be causing the problem. So far, the only way to counter the problem is to hardcode the value in the
property file, which to me, defeats the purpose of profiles.


Jayesh A Lalwani
Saloon Keeper

Joined: Jan 17, 2008
Posts: 2678

maybe you have filtering turned out for that particular file
John Gregory
Ranch Hand

Joined: Oct 05, 2006
Posts: 118


I'd have to say no, I'm not filtering. Within the properties file, there are about 10 different properties
I vary depending on environment, prod, development. In every case except the one, the value is
not picked up. This is frustrating because it's non consistent across poms. In a different pom, that
value will be set. To further complicate this, I copy/paste the profile values from pom-to-pom.
So there's no reason why it would work in one application and not the other.

Peter Johnson

Joined: May 14, 2008
Posts: 5852

Have you run the mvn build with the -X option? If I recall correctly, that option prints out all of the property values that it knows about. (The object here is to see if Maven is correctly reading the property value.)

I would then try changing the property name, say to "storekey", and see if that starts working. (The object here is to see if the word 'keystore' is somehow special.)

Does the @ character appear anywhere in the properties file? The text filtering mechnism uses two ways to define tokens: ${...} and @...@. Thus stray @'s can cause issues (I run into this every time I need to filter .bat files). To overcome this problem, see the 'delimeters' parameter: http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#delimiters

JBoss In Action
John Gregory
Ranch Hand

Joined: Oct 05, 2006
Posts: 118

Thanks for the suggestion. I'll give the -X option a try when I get in on Mon. However as for it being a delimiter
issue, maybe. The thing is, I have another parameter, truststore, which does get set. Maybe it's bombing
after parsing the value for that...


James Boswell

Joined: Nov 09, 2011
Posts: 1051

There is a bug with the resources plugin which I found out about on a previous project:


This exists in versions prior to 2.5. Which version are you on? And do you have the @ token in your properties file.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17145

Jayesh A Lalwani wrote:maybe you have filtering turned out for that particular file

What Jayesh is saying is that substitutions are not automatic when Maven copies properties files to build a target. You must designate a filter directory to hold sources which are to have substitution performed on them when they are copied.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link: http://aspose.com/file-tools
subject: maven not populating properties from profile
It's not a secret anymore!