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]


An example of variable references within an annotation:


An example of variable references within a web.xml descriptor


An example of multiple variable references combined in a single value withing the domain.xml:

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

An example of variable references 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}