I have a bluemix app pushed via packaged liberty server. The app looks for the instance IP/hostname internally. When the app is upscaled with more than one instance, using localhost as the hostname becomes obsolete. Host entry is set in our server.xml.
When i tried to use Referenceable variables such as ${host} or ${vcap_console_ip}, it is not getting the host name or ip address respectively.
Looking for suggestion on how to get the host name or ip of the instance the app is running into my server.xml.
You could use the VCAP_APPLICATION env variable and get the "uris" attribute.
String VCAP_APPLICATION = System.getenv("VCAP_APPLICATION");
if (VCAP_APPLICATION != null) {
JsonNode node = Json.mapper().readValue(VCAP_APPLICATION, JsonNode.class);
ArrayNode uris = (ArrayNode) node.get("uris");
if (uris != null && uris.size() > 0 && uris.get(0) != null) {
host = uris.get(0).textValue();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With