javajbosswildflythorntail

How to escape ${...} (so they are not evaluated as expressions) in properties files in Wildfly/Thorntail


I'm starting a Thorntail hollowjar and passing in --properties=environment.properties. This file contains a property with a ${...} expression that is not meant for Thorntail to evaluate, but rather for my application to consume as is. However, Thorntail bombs out with an error:

[org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: (("system-property" => "myPropertyName")) - failure description: "WFLYCTL0211: Cannot resolve expression 'My property value with ${expression}'"

How do I escape the ${...} so that it will be interpreted literally? Or can I globally disable expression evaluation in system properties somehow? I've Googled everywhere, but nothing about this seems to be documented.


Solution

  • OK, so after looking in the code (org.jboss.as.controller.ExpressionResolverImpl) I saw that two dollar signs are replaced by one, so to avoid expression expansion, instead of ${abc}, do $${abc}.

    Why they thought it was a good idea to write their own expression evaluator when there are already many good ones out there is beyond me ¯\_(ツ)_/¯