JBoss EAP 6 environment variables: standalone vs. domain

environment-variablesjbossjboss7.x

I am trying to set up some environment variables for my standalone JBoss EAP 6 instance, but the code does not seem to pick it up.

Here is what I had to do in my startjboss.sh for JBoss EAP 5:

export MYSPECIALIP=127.0.0.1
nohup run.sh

In JBoss EAP 6, in domain mode, I changed host.xml file on my host to include the following:

<jvms>
    <jvm name="default">
        <environment-variables>
            <variable name="MYSPECIALIP" value="127.0.0.1"/>
        </environment-variables>
        <heap size="64m" max-size="256m"/>
        <permgen size="256m" max-size="256m"/>
        <jvm-options>
            <option value="-server"/>
        </jvm-options>
    </jvm>
</jvms>

Now, I would like to know how to do it for JBoss EAP 6 standalone mode? So far I tried to add it in standalone.conf alongside Java options, but it did not work.

JAVA_OPTS="-Xmx3g -Xms3g -XX:MaxPermSize=256m $JAVA_OPTS"
MYSPECIALIP=127.0.0.1

Best Answer

1.Go to /home/user/.bash_profile

a. Edit .bash_profile and make entries of name-value pairs

        -- dbIP=10.10.10.10
        -- db_user_name=abc
        -- db_password=def
        -- dbName=qwerty
        -- host=localhost

b. Also these entries must be exported by prefixing "export" infront of these name of name-value pair as

        -- export dbIp=10.10.10.10
        -- export db_user_name=abc
        -- export db_password=def
        -- export dbName=qwerty
        -- export host

2.Make entries of these name-value pairs in standalone.xml with "env." notation as prefix

        -- ${env.dbIp}
        -- ${env.dbName}
        -- ${env.db_user_name}
        -- ${env.db_password}
        -- ${env.secret_pwd}
        -- ${env.host}

  * In standalone.xml, you can see entries like this :

      <datasources>
        <datasource jndi-name="java:jboss/datasources/ExampleDS" 
                    pool-name="ExampleDS" enabled="true">
                 <connection-url>${env.dbIp}:${env.port}:${env.dbName}</connection-url>
                 <driver>oracle</driver>
                        ......
            ......                  
                <datasource>
             </datasources>

NOTE : "$" represents environtmental variable

3.Run bash profile as . ./.bash_profile

4.Run JBoss in standalone mode as ./standalone.sh