I have a WildFly 10 pod and a mysql 5.7 pod running in Openshift V3. I would like to use environment variables in my standalone.xml as I was used in Openshift V2 to configure my mysql datasource.
I followed this guide: https://github.com/openshift-s2i/s2i-wildfly
I added a .s2i folder and created there a file called: environment.
I added to the 'environment' file the following key:
MYSQL_DATABASE=<DATABASE_NAME>
The <DATABASE_NAME>
is of course replaced with the real database name.
In my standalone.xml I have:
<subsystem xmlns="urn:jboss:domain:datasources:4.0">
<datasources>
<datasource jta="false" jndi-name="java:/<DATABASE_NAME>" pool-name="pool_name" enabled="true" use-ccm="false">
<connection-url>jdbc:mysql://MYSQL_SERVICE_HOST:MYSQL_SERVICE_PORT/<DATABASE_NAME>?useSSL=false</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver>mysql</driver>
<security>
<user-name>MYSQL_USER</user-name>
<password>MYSQL_PASSWORD </password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker"/>
<background-validation>true</background-validation>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter"/>
</validation>
</datasource>
<drivers>
<driver name="mysql" module="com.mysql.jdbc">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
When replacing the environment variables by the real values, the mysql connection works and wildfly boots up with success.
What am I doing wrong?
I also prefixed each environment variable in standalone.xml with the dollar sign but still no luck...