It's likely your machine's configuration. Check that DNS for the domain resolves properly and that there is a domain set.
Java will either lookup in /etc/hosts
or use you OS facilities to do the name address to name resolution.
Since you're looking for localhost, you may need a host specific mechanism to resolve it.
Also your machine likely has many interfaces, and not all of them may resolve to the same FQDN.
It may help to enumerate all network interfaces to see what's wrong:
final Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while(networkInterfaces.hasMoreElements())
{
final NetworkInterface iface = networkInterfaces.nextElement();
System.out.println("Interface: " + iface.getDisplayName());
final Enumeration<InetAddress> inetAddresses = iface.getInetAddresses();
while (inetAddresses.hasMoreElements())
{
final InetAddress addr = inetAddresses.nextElement();
System.out.println(addr.getCanonicalHostName());
}
}