0

We are using wildfly 8.0 version for our legacy application. We are trying to pass datasource value as parameter in standalone.xml file but wildfly is throwing error as it's not recognizing $ sign.

standalone.xml

${DB_URL}

can anyone explain how to pass parameters in wildfly 8.0 server. We are starting our server as service.

service wildfly start

Here is snippet of standalone.xml

<profile>
 <subsystem xmlns="urn:jboss:domain:logging:2.0">
  <subsystem xmlns="urn:jboss:domain:datasources:2.0">
            <datasource jta="false" jndi-name="java:jboss/postgresDSPC" pool-name="postgresDSPC" enabled="true" use-java-context="true" use-ccm="false">
                    <connection-url>${DB_URL}</connection-url>
                    <driver>postgresql</driver>
                    <pool>
                        <min-pool-size>2</min-pool-size>
                        <max-pool-size>20</max-pool-size>
                    </pool>
                    <security>
                        <user-name>username</user-name>
                        <password>password</password>
                    </security>
                    <statement>
                        <prepared-statement-cache-size>50</prepared-statement-cache-size>
                        <share-prepared-statements>false</share-prepared-statements>
                    </statement>
              </datasource>
   </subsystem>
  <subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>             

Here is the value I see when I read using jboss-cli

  "connection-url" => {
                "type" => STRING,
                "description" => "The JDBC driver connection URL",
                "expressions-allowed" => true,
                "nillable" => false,
                "min-length" => 1L,
                "max-length" => 2147483647L,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },

Thanks Rakesh

Rakesh
  • 177
  • 2
  • 14
  • How looks the relevant section in your standalone.xml? What's the exact error message? Basically not all modules are supporting property resolution with the ${...} syntax. DataSources should work afaik. You can check it with cli :read-resource-description(recursive=true) Look for the 'expression-allowed' flag. – Laertes Jan 19 '20 at 17:14
  • Here is the error.. ]) - failure description: "JBAS014802: Cannot resolve expression 'expression \"${DB_URL}\"' -- java.lang.IllegalStateException: Failed to resolve expression: ${DB_URL}" 2020-01-19 04:40:54,249 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - – Rakesh Jan 19 '20 at 17:26
  • Sure that the property is set? How do you set it? (And again: How looks the section in standalone.xml) – Laertes Jan 19 '20 at 17:39
  • attached standalone.xml snippet. we are setting property as environment variable on shell. – Rakesh Jan 20 '20 at 15:02

1 Answers1

1

For environmental variables you will have to use the env. prefix. e.g.

${env.DB_URL} 
Laertes
  • 334
  • 1
  • 6
  • Thank you so much for your help.It seems when we start service as . "service wildfly start" seems not working while if i run ./standalone.sh -D with all other parameters works. – Rakesh Jan 21 '20 at 15:34
  • Didn't it work with the 'env.' prefix? With the -D parameter you are setting (Java) SystemParameters. They are not the same as the (OS) environmental parameter you mentioned earlier. To refer to environmental parameter in the standalone.xml the 'env.' prefix should work. – Laertes Jan 21 '20 at 19:34
  • Thxs, so you might consider to close your question by clicking the checkmark to the left of the answer. – Laertes Jan 22 '20 at 19:11