We just upgraded to Java 8 on Amazon Linux. We are using Spring 4.3.8.RELEASE. It used to be that we could get our machine hostname by setting up beans in our application context file like so ...
<bean id="localhostInetAddress" class="java.net.InetAddress" factory-method="getLocalHost" /> <bean id="hostname" factory-bean="localhostInetAddress" factory-method="getHostName" /> But with Java 8, the bean "hostname" now contains the string
localhost Before Java 8, it used to contain the "hostname" value as run on the command line, which is
[myuser@machine1 ~]$ hostname machine1.mydomain.org How can I reconfigure our bean so that it gets the hostname that the command line lists out? I don't want to hard-code anything anywhere.
getLocalHost(): “If the operation is not allowed, an InetAddress representing the loopback address is returned.” You may also try usinggetCanonicalHostName()to get an fqn rather thangetHostName()exec(hostname)... and they state that on AmazonInetAddress.getLocalHost()returns (sometimes) the loopback device, which islocalhost. I might need to ping the author of these lines to understand what is going on actually