Chapter 4. Environment variables and model expression resolution


4.1. Prerequisites

  • You have some basic knowledge of how to configure environment variables on an operating system.
  • For configuring environment variables on the OpenShift Container Platform, you must meet the following prerequisites:

To resolve management model expressions and to start your JBoss EAP 8.1 server on the OpenShift Container Platform, you can either add environment variables or set Java system properties in the management command-line interface (CLI). If you use both, JBoss EAP observes and uses the Java system property rather than the environment variable to resolve the management model expression.

System property to environment variable mapping

Imagine that you have this management expression: ${my.example-expr}. When your JBoss EAP server tries to resolve it, it checks for a system property named my.example-expr.

  • If your server finds this property, it uses its value to resolve the expression.
  • If it doesn’t find this property, your server continues searching.

Next, assuming that your server does not find system property my.example-expr, it automatically changes my.example-expr to all uppercase letters and replaces all characters that aren’t alphanumeric with underscores (_): MY_EXAMPLE_EXPR. JBoss EAP then checks for an environment variable with that name.

  • If your server finds this variable, it uses its value to resolve the expression.
  • If it doesn’t find this variable, your server continues searching.
Tip

If your original expression starts with the prefix env., JBoss EAP resolves the environment variable by removing the prefix, then looking for only the environment variable name. For example, for the expression env.example, JBoss EAP looks for an example environment variable.

If none of these checks finds a property or variable to resolve your original expression, JBoss EAP looks for whether the expression has a default value. If it does, that default value resolves the expression. If not, then JBoss EAP can’t resolve the expression.

Example with two servers

Suppose that, on one server, JBoss EAP defines this management resource: <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">. To run a second server with a different port offset, instead of editing the configuration file, do one of the following:

  • Set the jboss.socket.binding.port-offset Java system property to resolve the value on the second server: ./standalone.sh -Djboss.socket.binding.port-offset=100.
  • Set the JBOSS_SOCKET_BINDING_PORT_OFFSET environment variable to resolve the value on the second server: JBOSS_SOCKET_BINDING_PORT_OFFSET=100 ./standalone.sh.

With JBoss EAP 8.1, you can configure environment variables to resolve management model expressions. You can also use environment variables to adapt the configuration of the JBoss EAP server you’re running on OpenShift.

Set environment variables and options on a resource that uses a pod template:

$ oc set env <object-selection> KEY_1=VAL_1 ... KEY_N=VAL_N [<set-env-options>] [<common-options>]
Copy to Clipboard Toggle word wrap
Expand
OptionDescription

-e, --env=<KEY>=<VAL>

Set given key-value pairs of environment variables.

--overwrite

Confirm update of existing environment variables.

Note

Kubernetes workload resources that use pod templates include the following:

  • Deployment
  • ReplicaSet
  • StatefulSet
  • DaemonSet
  • Job
  • CronJob

After you configure your environment variables, the JBoss EAP management console should display them in the details for their related pods.

You know that you can use a Java system property or an environment variable to resolve a management attribute that’s defined with an expression, but you can also modify other attributes, even if they don’t use expressions.

To more easily adapt your JBoss EAP server configuration to your server environment, you can use an environment variable to override the value of any management attribute, without ever having to edit your configuration file. This feature, which is available starting with the JBoss EAP version 8.0, is useful for the following reasons:

  • JBoss EAP provides expressions for only its most common management attributes. Now, you can change the value of an attribute that has no defined expression.
  • Some management attributes connect your JBoss EAP server with other services, such as a database, whose values you can’t know in advance, or whose values you can’t store in a configuration; for example, in database credentials. By using environment variables, you can defer the configuration of such attributes while your JBoss EAP server is running.
Important

This feature is enabled by default, starting with JBoss EAP version 8.0 OpenShift runtime image. To enable it on other platforms, you must set the WILDFLY_OVERRIDING_ENV_VARS environment variable to any value; for example, export WILDFLY_OVERRIDING_ENV_VARS=1.

Note

You can’t override management attributes whose type is LIST, OBJECT, or PROPERTY.

Prerequisites

  • You must have defined a management attribute that you now want to override.

Procedure

  1. Identify the path of the resource and attribute you want to change. For example, set the value of the proxy-address-forwarding attribute to true for the resource /subsystem=undertow/server=default-server/http-listener=default.
  2. Create the name of the environment variable to override this attribute by mapping the resource address and the management attribute, as follows:

    1. Remove the first slash (/) from the resource address: /subsystem=undertow/server=default-server/http-listener=default becomes subsystem=undertow/server=default-server/http-listener=default.
    2. Append two underscores (__) and the name of the attribute; for example: subsystem=undertow/server=default-server/http-listener=default__proxy-address-forwarding.
    3. Replace all non-alphanumeric characters with an underscore (_), and put the entire line of code in all capital letters: SUBSYSTEM_UNDERTOW_SERVER_DEFAULT_SERVER_HTTP_LISTENER_DEFAULT__PROXY_ADDRESS_FORWARDING.
  3. Set the environment value: SUBSYSTEM_UNDERTOW_SERVER_DEFAULT_SERVER_HTTP_LISTENER_DEFAULT__PROXY_ADDRESS_FORWARDING=true.

    Note

    These values are examples that you must replace with your actual configuration values.

Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat