How to resolve the java.net.UnknownHostException error

1

I'm trying to install sqldeveloper and datamodeler in my Fedora 20 and I'm having problem with following error:

java.net.UnknownHostException: localdomain: localdomain: Name or service not known
        at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
        at org.netbeans.CLIHandler$2.run(CLIHandler.java:667)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2044)
Caused by: java.net.UnknownHostException: localdomain: Name or service not known
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
        at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
        at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
        at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
        ... 3 more

I'm running Java 1.7.0_51 installed.

    
asked by anonymous 06.03.2014 / 01:28

2 answers

3

This error occurs because the Java domain name resolution is wanting the host name.

To resolve use:

HostnameVerifier hv = new HostnameVerifier() {
    public boolean verify(String hostname, SSLSession session) {  
        return true;
    }
};

So the name resolution will be ignored. Put this code before before the connection call is RMI, Socket or Webservice.

    
11.03.2014 / 18:21
3

I found out how to fix the bug.

In case the application is starting a host using the machine name localdomain and trying to access it by name, as this name has no related IP it is giving this error.

I edited the file /etc/hosts and added the following line:

127.0.0.1    localdomain

This was enough for him to recognize the domain name and find it, causing both applications to stop giving error.

    
06.03.2014 / 01:37