Can I directly use ${MPCONFIG=db_host} expression in web.xml using a property set in microprofile-config.properties ?

123 views
Skip to first unread message

Julien Sié

unread,
Nov 14, 2019, 11:52:19 AM11/14/19
to Payara Forum

Good afternoon.


I feel a little bit confused about the last sentence "MicroProfile properties need to be declared in one of the Payara defined config sources"...

I've declared the property "db_host=localhost" in the file microprofile-config.properties but this property doesn't seem loaded/resolved using it in web.xml.
However, I can load this property injecting the property in a bean (with @Inject @ConfigProperty(name="db_host")) and it works.
I've also followed the documentation and created a microprofile config property using the command asadmin set-config-property and the value is now resolved in the web.xml !

So, my question is : Is it possible to use a property defined in the file microprofile-config.properties in web.xml (a data-source for e.g.) or is it necessary to declare these properties using asadmin set-config-property command line ?

Thanks for your advises.

Steve Millidge

unread,
Nov 14, 2019, 12:48:05 PM11/14/19
to Payara Forum
Hi 

As you have found out it is not possible to override a property in web.xml with a property set in an application microprofile-config.properties due to the order in which things are initialised when deploying an application. For example the first thing to happen is that the web.xml is parsed so the properties are not available at that point in time if stored in the war file whereas properties set at the system level are. 

Steve

Julien Sié

unread,
Nov 14, 2019, 12:55:44 PM11/14/19
to Payara Forum
Thank you very much for your fast answer, Steve. 
It's pretty clear.

Anyway, I'll try to move the data-source definition from the web.xml into a @DataSourceDefinition annotation.
Is it the same behaviour? I mean the ${MPCONFIG=db_host} won't be parsed/resolved in the annotation?

Steve Millidge

unread,
Nov 14, 2019, 1:04:17 PM11/14/19
to Payara Forum
To be honest I can't remember without trying it. I suspect the behaviour will be the same.

Julien Sié

unread,
Nov 15, 2019, 6:51:17 AM11/15/19
to Payara Forum
... and you're right. Same behaviour.
Reply all
Reply to author
Forward
0 new messages