Using variable references

A variable can be referenced anywhere inside a string value of a property which supports variable references. Multiple references to system properties and environment variables can be used within the same configuration value, concatenating any number of variable references and plain text chunks. When a reference to a password alias is used, it has to expand to the whole property value and cannot be combined with any other text or variable references.

Variable references in the domain configuration

Variable references can be used inside text values in the following configuration files within the domain directory:

  • domain.xml (inside attribute values or inside text nodes that contain a configuration value)

  • (inside property values)

Variable references in deployed applications

Since Payara Server

Variable references can be used inside text values also in the following places within deployed applications and modules:

  • Package descriptors:

    • web.xml / glassfish-web.xml

    • ejb-jar.xml / glassfish-ejb-jar.xml

    • application.xml / glassfish-application.xml

    • glassfish-resources.xml

  • Framework descriptors:

    • persistence.xml

    • faces-config.xml

  • In the annotations:

    • @EJB, @WebService, @Stateless, @Stateful, @Singleton, @ActivationConfigProperty, @DataSource, @WebServlet

  • In JNDI lookups inside an application

  • In pre and post boot command files. [Since Payara Server]

  • In JVM Options. [Since Payara Server and 5.182]

  • In file [Since Payara Server 5.20.0].


Here are several examples of where you can use variable references:

Within an annotation


Within a web.xml descriptor


Multiple variable references combined in a single value withing the domain.xml

<domain log-root="${com.sun.aas.instanceRoot}/${ENV=STAGE_NAME}/logs">

Within a pre or post boot command file

set configs.config.server-config.http-service.virtual-server.server.default-web-module=${ENV=deployed-app-name}

Within a file

Environment variable substitution in the logging properties file is available since Payara Server 5.184

Within a file

The config source is only available in Payara Server since 5.20.0
fish.payara.example.multiple=property containing both an ${ENV=envProperty} and a ${sysProp}