0 votes
1 view
in Devops and Agile by (29.9k points)

I am setting up a common standalone-full.xml file for all server environments, and therefore need to have variables for database URL's (and such), instead of hard coding them.

One such section in the configuration file might look like this:

<datasource jta="true" jndi-name="java:/somename" pool-name="somename" enabled="true" use-ccm="false">




















However, upon starting the server with this config file it simply throws an "Unable to resolve expression" error for all such sections.

I've tried putting the variables in /etc/environment, as well as in the .jbossclirc file in /bin using set DB_USERNAME=mydbusername, but to no avail.

As you can see I'm fumbling a bit in the dark here since I haven't been able to find any proper documentation on how to do this. I'm not even sure if it's actually possible. Any help is greatly appreciated.

1 Answer

0 votes
by (51.2k points)

For this, you can use Java system properties instead of environment variables.

Pass -D arguments to standalone.sh 

Let’s see how to pass this -D arguments with an example

bin/standalone.sh -DDB_USERNAME=me -DDB_PASSWORD=secret

There is one more alternative way where you can define your properties in a properties file and pass this to startup script with -p options 

Let’s see this with an example

bin/standalone.sh -P database.properties

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !