6 Replies Latest reply on Aug 7, 2016 11:04 PM by pahuang

    system environment variables with cli

    demarcojb

      Hi together.

      In former jboss versions there is the possibility to define system properties in datasource-xml files f.e. in the following way:

      <connection-url>jdbc:sapdb://${MY_SERVER}/database</connection-url>

       

      Where ${MY_SERVER} is analysed during runtime. This also worked in wildfly 9, if I'm modifying the standalone-full.xml with an editor.

      But what I want is to define exactly this entry with cli. But I always get a "Cannot resolve expression" Error.

      Problem seems that the $ always will be interpreted by the cli during define phase as system-property normally defined in the <system-properties>-Element of standalone-full.xml. I didn't find a way to quote the $.

       

      How can I do that? As result I simply want as result the string "<connection-url>jdbc:sapdb://${MY_SERVER}/database</connection-url>" in the standalone-full.xml defined by cli.

       

      Thanks

      Marco

        • 1. Re: system environment variables with cli
          jaikiran

          What is the exact command you are using in the CLI to add that system property?

          • 2. Re: system environment variables with cli
            ctomc

            not sure what exactly are you facing but just in case.

             

            ${MY_SERVER} would lookup system property aka System.getProperty("MY_SERVER")

            ${env.MY_SERVER} would lookup environment property aka System.getEnv("MY_SERVER")

             

            not sure what you want to use

            • 3. Re: system environment variables with cli
              jaikiran

              I think the user meant that he wants to literally set the connection URL to contain the ${MY_SERVER} sub string, but isn't able to do so from the CLI apparently because he isn't aware how to escape the $ sign.

               

              ... and I don't know myself if the \ (backslash) would work in this case, so I just asked the user to paste his command so someone might be able to fix it.

              • 4. Re: system environment variables with cli
                demarcojb

                Hi together. Thanks for your answers!

                jaikiran pai; that's exactly what I want! The command is f.e.:

                 

                data-source add \

                --name=mydatabase \

                --jndi-name=java:/MYDATABASE \

                --driver-name=maxdb_7_6 \

                --connection-url=jdbc:sapdb://${MY_SERVER} \

                --user-name=myuser \

                --password=mypassword \

                --min-pool-size=10 \

                --max-pool-size=100 \

                --idle-timeout-minutes=15 \

                --blocking-timeout-wait-millis=5000

                 

                Problem is that I don't know how to quote the "$". "\" also seems not working...

                Thanks for your effort and best regards

                Marco

                • 5. Re: system environment variables with cli
                  demarcojb

                  Are there any news? It seems to be a missing feature...?!

                  • 6. Re: system environment variables with cli
                    pahuang

                    In case anyone is searching for a solution:

                    There is a workaround posted here http://stackoverflow.com/a/29824058/345718

                     

                    So basically you put a : after the variable like --connection-url=jdbc:sapdb://${MY_SERVER:}

                    Sometimes you may have complains "WFLYCTL0113: '' is an invalid value for parameter user-name. Values must have a minimum length of 1 characters"}. Just put a dummy value after : to get pass it. e.g. --user-name=${env.DB_ENV_POSTGRES_USER:postgres}