1

I have properties file in local to which I am reading in code by below method String pathOfFile = System.getProperties("arg.get.prop");

How to set this system properties to get my property file's path in liberty server.xml

3 Answers 3

2

You can specify environment variables in the server.env file placed either in ${wlp.install.dir}/etc/server.env or ${server.config.dir}/server.env. The server will also pick up variables from the current shell environment (server.env files take precedence). Then you can access the variables in the server.xml using the following notation:

${env.<variable name>} 

For example, you can have the following in your server.env file:

HTTP_PORT=9001 

and then in your server.xml:

<httpEndpoint id="defaultHttpEndpoint" httpPort="${env.HTTP_PORT}" httpsPort="9443" /> 

For more information on customizing the Liberty environment see: https://www.ibm.com/support/knowledgecenter/en/SSAW57_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_admin_customvars.html

Sign up to request clarification or add additional context in comments.

Comments

0

If you need to define system property the recommended way is to use jvm.options file and put your property there like:

# Set a system property. -Darg.get.prop=ExampleValue 

you may need to create that file in the ${server.config.dir} directory. For some more details check Customizing the Liberty environment

1 Comment

According to you if my key value pair is name.stack.flow=solution .Then I will write in jvm.option as Dname.stack.flow=solution .RIGHT
0

if your property file is in "variable=value" format .. then, you can include in in bootstrap.properties file of your liberty install.

bootstrap.properties can be used to supply variable values to liberty configuration. you can include additional files by specifying bootstrap.include=

1 Comment

the downside of bootstrap.properties is that they get set after JVM starts up, so isn't good for system properties the JVM reads. This is only really good for JVM options an application reads.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.