Override System Properties on a deployment basis?

265 views
Skip to first unread message

Florian Troßbach

unread,
Jan 16, 2023, 10:26:41 AM1/16/23
to WildFly
Hi,

I'm using WildFly 27.0.1 and I have a question about the feasiblity of the following scenario:

We use system-properties in the WildFly to set some variables that are valid for all deployments on a given standalone server. However, we recently found we have a need to override one of those values for just one deployed application. Is that possible with some wildfly deployment descriptor?

http://www.mastertheboss.com/jbossas/jboss-configuration/how-to-inject-system-properties-into-jboss/ says I should put a file called "jboss.properties" in META-INF of my war, but that does not work for me, it simply uses the value from WildFly configuration (that I can see in standalone.xml). 

Is it possible to do this and what do I need to do?

Thanks in advance!

Richard Opalka

unread,
Jan 17, 2023, 4:27:02 AM1/17/23
to Florian Troßbach, WildFly
Hello Florian,

    jboss.properties must be in 'root' archive so if your war is nested in the ear file then META-INF/jboss.properties must be moved to the ear.

Rio

--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wildfly/e8bb0dc9-0049-4d87-8de0-62b2a8d90562n%40googlegroups.com.

Florian Troßbach

unread,
Jan 19, 2023, 3:04:17 PM1/19/23
to WildFly
Hi Rio,

You're right that my war was wrapped inside an ear. But it still doesn't work for me. 
The file is right there in the EAR, in /META-INF/jboss.properties.alongside application.xml and jboss-deployment-structure.xml. The latter two are evaluated.

 I included two properties in jboss.properties, one which should override a server-wide system property and a new one.

The overriding one returns the system-wide value. The new one evaluates to null when using "System.getProperty()". It feels like that file is ignored.

Cheers,
Florian

Richard Opalka

unread,
Jan 23, 2023, 6:34:37 AM1/23/23
to Florian Troßbach, WildFly
Hello Florian,

   jboss.properties content cannot be accessed via System.getProperty() method.
It is a static method and any change to it would be visible in the whole JVM.
I had a quick look at WildFly code base and jboss.properties if available in deployment
its content may be used in deployment descriptors in the form ${some.property} to parametrize your application.

Here's one example:


Rio


Reply all
Reply to author
Forward
0 new messages