1

How can I pass MP config property file to OL on the command line? The wlp/bin/server.bat does not allow to pass even Java system properties...

I have looked at the OL MP config example and it assumes that the configuration is in the user user.home system property - not very useful.

I read the various WS Liberty docs and they require me to configure in XML the location where the property file is - also not very flexible. Other options involve using environment variables - not what I want.

What I want is something as flexible as:

bin/server.bat -Dmy.conig=c:/temp/myconfig.properties

This example above is similar to how Spring/SpringBoot does it. Thanks!

Hristo Stoyanov
  • 1,508
  • 3
  • 15
  • 24
  • You can create multiple jvm.options files in the following locations: ${wlp.install.dir}/usr/shared/jvm.options ${server.config.dir}/configDropins/defaults/jvm.options ${server.config.dir}/jvm.options ${server.config.dir}/configDropins/overrides/jvm.options – covener Jan 06 '18 at 23:17
  • or native environment variable JVM_ARGS – covener Jan 06 '18 at 23:18
  • So, there is no way to just pass some options from the command line, which is the most flexible option? – Hristo Stoyanov Jan 07 '18 at 07:04

1 Answers1

2

There are a few solutions for your use case:

  1. Use your properties file as the default config in the app by placing your file inside the app under META-INF\microprofile-config.properties for jar or WEB-INF\classes\META-INF\microprofile-config.properties

  2. Use your config as default jvm properties by using the instruction provided by covener. You can put the content of myconfig.properties into jvm.options or just rename your file to be jvm.options but place under one of the locations mentioned by covener.

  3. Use your properties file as a custom config source. You can directly implement MicroProfile config api ConfigSource to parse this property file and provide the name value pairs for your app.

You can find more info about MicroProfile config from the open liberty guide (https://openliberty.io/guides/microprofile-config-intro.html)

Emily Jiang
  • 151
  • 3
  • Thanks Emily, I was not aware of the tutorial! 1. Does not work for me, as I mentioned bundling property files is not flexible. 2. and 3. kind of work, but waht would really flexible is a command line switch to pass in server-level properties file without changing any configuration. This is the most flexible approach and would work nicely with Docker, where the image can be dynamically and very flexible configured. Environment variable is not really secure (for passwords, etc) – Hristo Stoyanov Jan 11 '18 at 21:54
  • Where was your docker imaged deployed? If it is in Kube environment, I recommend you use secrets to store secure info such as password and put all other properties in config map. The properties from these areas are automatically made to Liberty as environment variables. If this is not what you want, feel free to open an issue on https://github.com/OpenLiberty/open-liberty/issues/new. – Emily Jiang Jan 12 '18 at 10:17
  • Emily,I need to be able to create one docker image with immutable OL binaries and store any Microprofile configurations in an attched data volume. In this case command line params to the server works best for both development and deployment in the container – Hristo Stoyanov Jan 12 '18 at 23:29
  • Thanks for your explanation and your patience! Please raise an issue on Open Liberty https://github.com/OpenLiberty/open-liberty/issues/new. – Emily Jiang Jan 15 '18 at 10:22